Made a breaking change to the mscript module: light array is now the "meta" array to allow for types of commands other than camera movements to have associated metadata. The two driving motivations for this change are the proposed alert feature which will have a string message as its metadata and the proposed pause feature, which will have seconds as its metadata.

Updated tests as well. Still need to change behavior in the mscript.js gui lib.
This commit is contained in:
mmcwilliams 2019-07-26 19:54:22 -04:00
parent c01f3ceff8
commit 96d0897f65
8 changed files with 137 additions and 104 deletions

View File

@ -60,7 +60,7 @@ class Mscript {
this.rec = -1; this.rec = -1;
this.two = ''; this.two = '';
this.arr = []; this.arr = [];
this.light = []; this.meta = [];
this.target = 0; //move to target using CAM # or PROJ # this.target = 0; //move to target using CAM # or PROJ #
this.dist = 0; this.dist = 0;
this.variables = {}; this.variables = {};
@ -125,11 +125,12 @@ class Mscript {
else if (startsWith(line, 'ALERT')) { else if (startsWith(line, 'ALERT')) {
} }
else if (startsWith(line, 'PAUSE')) { else if (startsWith(line, 'PAUSE')) {
this.pause(line);
} }
} }
this.output.success = true; this.output.success = true;
this.output.arr = this.arr; //all instructions this.output.arr = this.arr; //all instructions
this.output.light = this.light; //all light instructions this.output.meta = this.meta; //all metadata for instructions
this.output.cam = this.cam; this.output.cam = this.cam;
this.output.proj = this.proj; this.output.proj = this.proj;
if (typeof callback !== 'undefined') { if (typeof callback !== 'undefined') {
@ -200,12 +201,12 @@ class Mscript {
//hold generated arr in state loop array //hold generated arr in state loop array
this.loops[this.rec].arr this.loops[this.rec].arr
.push.apply(this.loops[this.rec].arr, this.str_to_arr(line, this.two)); .push.apply(this.loops[this.rec].arr, this.str_to_arr(line, this.two));
this.loops[this.rec].light this.loops[this.rec].meta
.push.apply(this.loops[this.rec].light, this.light_to_arr(line, this.two)); .push.apply(this.loops[this.rec].meta, this.light_to_arr(line, this.two));
} }
else { else {
this.arr.push.apply(this.arr, this.str_to_arr(line, this.two)); this.arr.push.apply(this.arr, this.str_to_arr(line, this.two));
this.light.push.apply(this.light, this.light_to_arr(line, this.two)); this.meta.push.apply(this.meta, this.light_to_arr(line, this.two));
} }
} }
/** /**
@ -218,7 +219,7 @@ class Mscript {
this.rec++; this.rec++;
this.loops[this.rec] = { this.loops[this.rec] = {
arr: [], arr: [],
light: [], meta: [],
cam: 0, cam: 0,
proj: 0, proj: 0,
cmd: line + '' cmd: line + ''
@ -233,29 +234,29 @@ class Mscript {
* @param {string} line Line to interpret * @param {string} line Line to interpret
*/ */
end_loop(line) { end_loop(line) {
let light_arr; let meta_arr;
let start; let start;
let end; let end;
let len; let len;
for (let x = 0; x < this.loop_count(this.loops[this.rec].cmd); x++) { for (let x = 0; x < this.loop_count(this.loops[this.rec].cmd); x++) {
light_arr = this.loops[this.rec].light; meta_arr = this.loops[this.rec].meta;
if (this.loops[this.rec].fade) { if (this.loops[this.rec].fade) {
start = this.loops[this.rec].start; start = this.loops[this.rec].start;
end = this.loops[this.rec].end; end = this.loops[this.rec].end;
len = this.loops[this.rec].fade_len; len = this.loops[this.rec].fade_len;
light_arr = light_arr.map(l => { meta_arr = meta_arr.map(l => {
return this.fade_rgb(start, end, len, x); return this.fade_rgb(start, end, len, x);
}); });
} }
if (this.rec === 0) { if (this.rec === 0) {
this.arr.push.apply(this.arr, this.loops[this.rec].arr); this.arr.push.apply(this.arr, this.loops[this.rec].arr);
this.light.push.apply(this.light, light_arr); this.meta.push.apply(this.meta, meta_arr);
} }
else if (this.rec >= 1) { else if (this.rec >= 1) {
this.loops[this.rec - 1].arr this.loops[this.rec - 1].arr
.push.apply(this.loops[this.rec - 1].arr, this.loops[this.rec].arr); .push.apply(this.loops[this.rec - 1].arr, this.loops[this.rec].arr);
this.loops[this.rec - 1].light this.loops[this.rec - 1].meta
.push.apply(this.loops[this.rec - 1].light, light_arr); .push.apply(this.loops[this.rec - 1].meta, meta_arr);
} }
} }
this.update('END', this.loop_count(this.loops[this.rec].cmd)); this.update('END', this.loop_count(this.loops[this.rec].cmd));
@ -274,7 +275,7 @@ class Mscript {
this.dist = this.target - this.cam; this.dist = this.target - this.cam;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('BF'); this.loops[this.rec].arr.push('BF');
this.loops[this.rec].light.push(BLACK); this.loops[this.rec].meta.push(BLACK);
this.update('BF'); this.update('BF');
} }
} }
@ -282,7 +283,7 @@ class Mscript {
this.dist = this.cam - this.target; this.dist = this.cam - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('BB'); this.loops[this.rec].arr.push('BB');
this.loops[this.rec].light.push(BLACK); this.loops[this.rec].meta.push(BLACK);
this.update('BB'); this.update('BB');
} }
} }
@ -292,7 +293,7 @@ class Mscript {
this.dist = this.target - this.cam; this.dist = this.target - this.cam;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('BF'); this.arr.push('BF');
this.light.push(BLACK); this.meta.push(BLACK);
this.update('BF'); this.update('BF');
} }
} }
@ -300,7 +301,7 @@ class Mscript {
this.dist = this.cam - this.target; this.dist = this.cam - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('BB'); this.arr.push('BB');
this.light.push(BLACK); this.meta.push(BLACK);
this.update('BB'); this.update('BB');
} }
} }
@ -318,7 +319,7 @@ class Mscript {
this.dist = this.target - this.proj; this.dist = this.target - this.proj;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('PF'); this.loops[this.rec].arr.push('PF');
this.loops[this.rec].light.push(''); this.loops[this.rec].meta.push('');
this.update('PF'); this.update('PF');
} }
} }
@ -326,7 +327,7 @@ class Mscript {
this.dist = this.proj - this.target; this.dist = this.proj - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('PB'); this.loops[this.rec].arr.push('PB');
this.loops[this.rec].light.push(''); this.loops[this.rec].meta.push('');
this.update('PB'); this.update('PB');
} }
} }
@ -336,7 +337,7 @@ class Mscript {
this.dist = this.target - this.proj; this.dist = this.target - this.proj;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('PF'); this.arr.push('PF');
this.light.push(''); this.meta.push('');
this.update('PF'); this.update('PF');
} }
} }
@ -344,7 +345,7 @@ class Mscript {
this.dist = this.proj - this.target; this.dist = this.proj - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('PB'); this.arr.push('PB');
this.light.push(''); this.meta.push('');
this.update('PB'); this.update('PB');
} }
} }
@ -618,6 +619,13 @@ class Mscript {
const color = str.replace('L ', '').trim(); const color = str.replace('L ', '').trim();
this.color = color; this.color = color;
} }
/**
* Interpret a pause command
*
* @param {string} line String containing pause command
**/
pause(line) {
}
/** /**
* Throw an error with specific message * Throw an error with specific message
* *

File diff suppressed because one or more lines are too long

View File

@ -159,8 +159,8 @@ END`;
&& obj.cam === 8 && obj.cam === 8
&& obj.proj === 8 && obj.proj === 8
&& obj.arr.length === 16 && obj.arr.length === 16
&& obj.light.length === 16 && obj.meta.length === 16
&& obj.light[0] === '0,0,0') { && obj.meta[0] === '0,0,0') {
pass = true; pass = true;
} }
assert.ok(pass, 'Basic cam/proj loop'); assert.ok(pass, 'Basic cam/proj loop');
@ -178,9 +178,9 @@ describe('mscript - Light', () => {
&& obj.cam === 1 && obj.cam === 1
&& obj.proj === 1 && obj.proj === 1
&& obj.arr.length === 2 && obj.arr.length === 2
&& obj.light.length === 2 && obj.meta.length === 2
&& obj.light[0] === '255,255,255' && obj.meta[0] === '255,255,255'
&& obj.light[1] === '') { && obj.meta[1] === '') {
pass = true; pass = true;
} }
assert.ok(pass, 'Basic light'); assert.ok(pass, 'Basic light');
@ -194,10 +194,10 @@ describe('mscript - Light', () => {
&& obj.cam === 2 && obj.cam === 2
&& obj.proj === 1 && obj.proj === 1
&& obj.arr.length === 3 && obj.arr.length === 3
&& obj.light.length === 3 && obj.meta.length === 3
&& obj.light[0] === '255,255,255' && obj.meta[0] === '255,255,255'
&& obj.light[1] === '' && obj.meta[1] === ''
&& obj.light[2] === '0,0,0') { && obj.meta[2] === '0,0,0') {
pass = true; pass = true;
} }
assert.ok(pass, 'Basic black'); assert.ok(pass, 'Basic black');
@ -210,9 +210,9 @@ describe('mscript - Light', () => {
&& obj.cam === 4 && obj.cam === 4
&& obj.proj === 0 && obj.proj === 0
&& obj.arr.length === 4 && obj.arr.length === 4
&& obj.light.length === 4 && obj.meta.length === 4
&& obj.light[0] === '1,1,1' && obj.meta[0] === '1,1,1'
&& obj.light[3] === '2,2,2') { && obj.meta[3] === '2,2,2') {
pass = true; pass = true;
} }
assert.ok(pass, 'Basic light'); assert.ok(pass, 'Basic light');
@ -233,9 +233,9 @@ PF 10`
assert.equal(obj.cam, 72, `Camera moves forward 72 frames`); assert.equal(obj.cam, 72, `Camera moves forward 72 frames`);
assert.equal(obj.proj, 10, 'Projector moves forward 10 frames'); assert.equal(obj.proj, 10, 'Projector moves forward 10 frames');
assert.equal(obj.arr.length, 82, 'Generates 82 steps'); assert.equal(obj.arr.length, 82, 'Generates 82 steps');
assert.equal(obj.light[0], '0,0,0', 'Fade starts with starting color'); assert.equal(obj.meta[0], '0,0,0', 'Fade starts with starting color');
assert.equal(obj.light[71], '10,20,30', 'Fade ends with ending color'); assert.equal(obj.meta[71], '10,20,30', 'Fade ends with ending color');
assert.equal(obj.light[72], '', 'Frame after fade is default color'); assert.equal(obj.meta[72], '', 'Frame after fade is default color');
}) })
const script2 = const script2 =
@ -252,9 +252,9 @@ CF 10`
assert.ok(obj.success, 'Mscript labeled output success'); assert.ok(obj.success, 'Mscript labeled output success');
assert.equal(obj.cam, 34, 'There are 34 camera frames'); assert.equal(obj.cam, 34, 'There are 34 camera frames');
assert.equal(obj.arr.length, 34, 'There are 34 steps in the script'); assert.equal(obj.arr.length, 34, 'There are 34 steps in the script');
assert.equal(obj.light[0], '25,255,125', 'First frame is equal to start color'); assert.equal(obj.meta[0], '25,255,125', 'First frame is equal to start color');
assert.equal(obj.light[23], '225,125,10', 'Last frame in fade is equal to end color'); assert.equal(obj.meta[23], '225,125,10', 'Last frame in fade is equal to end color');
assert.equal(obj.light[24], '225,125,10', 'First frame after fade is set using Light command'); assert.equal(obj.meta[24], '225,125,10', 'First frame after fade is set using Light command');
}) })
}) })

View File

@ -60,7 +60,7 @@ class Mscript {
this.rec = -1; this.rec = -1;
this.two = ''; this.two = '';
this.arr = []; this.arr = [];
this.light = []; this.meta = [];
this.target = 0; //move to target using CAM # or PROJ # this.target = 0; //move to target using CAM # or PROJ #
this.dist = 0; this.dist = 0;
this.variables = {}; this.variables = {};
@ -125,11 +125,12 @@ class Mscript {
else if (startsWith(line, 'ALERT')) { else if (startsWith(line, 'ALERT')) {
} }
else if (startsWith(line, 'PAUSE')) { else if (startsWith(line, 'PAUSE')) {
this.pause(line);
} }
} }
this.output.success = true; this.output.success = true;
this.output.arr = this.arr; //all instructions this.output.arr = this.arr; //all instructions
this.output.light = this.light; //all light instructions this.output.meta = this.meta; //all metadata for instructions
this.output.cam = this.cam; this.output.cam = this.cam;
this.output.proj = this.proj; this.output.proj = this.proj;
if (typeof callback !== 'undefined') { if (typeof callback !== 'undefined') {
@ -200,12 +201,12 @@ class Mscript {
//hold generated arr in state loop array //hold generated arr in state loop array
this.loops[this.rec].arr this.loops[this.rec].arr
.push.apply(this.loops[this.rec].arr, this.str_to_arr(line, this.two)); .push.apply(this.loops[this.rec].arr, this.str_to_arr(line, this.two));
this.loops[this.rec].light this.loops[this.rec].meta
.push.apply(this.loops[this.rec].light, this.light_to_arr(line, this.two)); .push.apply(this.loops[this.rec].meta, this.light_to_arr(line, this.two));
} }
else { else {
this.arr.push.apply(this.arr, this.str_to_arr(line, this.two)); this.arr.push.apply(this.arr, this.str_to_arr(line, this.two));
this.light.push.apply(this.light, this.light_to_arr(line, this.two)); this.meta.push.apply(this.meta, this.light_to_arr(line, this.two));
} }
} }
/** /**
@ -218,7 +219,7 @@ class Mscript {
this.rec++; this.rec++;
this.loops[this.rec] = { this.loops[this.rec] = {
arr: [], arr: [],
light: [], meta: [],
cam: 0, cam: 0,
proj: 0, proj: 0,
cmd: line + '' cmd: line + ''
@ -233,29 +234,29 @@ class Mscript {
* @param {string} line Line to interpret * @param {string} line Line to interpret
*/ */
end_loop(line) { end_loop(line) {
let light_arr; let meta_arr;
let start; let start;
let end; let end;
let len; let len;
for (let x = 0; x < this.loop_count(this.loops[this.rec].cmd); x++) { for (let x = 0; x < this.loop_count(this.loops[this.rec].cmd); x++) {
light_arr = this.loops[this.rec].light; meta_arr = this.loops[this.rec].meta;
if (this.loops[this.rec].fade) { if (this.loops[this.rec].fade) {
start = this.loops[this.rec].start; start = this.loops[this.rec].start;
end = this.loops[this.rec].end; end = this.loops[this.rec].end;
len = this.loops[this.rec].fade_len; len = this.loops[this.rec].fade_len;
light_arr = light_arr.map(l => { meta_arr = meta_arr.map(l => {
return this.fade_rgb(start, end, len, x); return this.fade_rgb(start, end, len, x);
}); });
} }
if (this.rec === 0) { if (this.rec === 0) {
this.arr.push.apply(this.arr, this.loops[this.rec].arr); this.arr.push.apply(this.arr, this.loops[this.rec].arr);
this.light.push.apply(this.light, light_arr); this.meta.push.apply(this.meta, meta_arr);
} }
else if (this.rec >= 1) { else if (this.rec >= 1) {
this.loops[this.rec - 1].arr this.loops[this.rec - 1].arr
.push.apply(this.loops[this.rec - 1].arr, this.loops[this.rec].arr); .push.apply(this.loops[this.rec - 1].arr, this.loops[this.rec].arr);
this.loops[this.rec - 1].light this.loops[this.rec - 1].meta
.push.apply(this.loops[this.rec - 1].light, light_arr); .push.apply(this.loops[this.rec - 1].meta, meta_arr);
} }
} }
this.update('END', this.loop_count(this.loops[this.rec].cmd)); this.update('END', this.loop_count(this.loops[this.rec].cmd));
@ -274,7 +275,7 @@ class Mscript {
this.dist = this.target - this.cam; this.dist = this.target - this.cam;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('BF'); this.loops[this.rec].arr.push('BF');
this.loops[this.rec].light.push(BLACK); this.loops[this.rec].meta.push(BLACK);
this.update('BF'); this.update('BF');
} }
} }
@ -282,7 +283,7 @@ class Mscript {
this.dist = this.cam - this.target; this.dist = this.cam - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('BB'); this.loops[this.rec].arr.push('BB');
this.loops[this.rec].light.push(BLACK); this.loops[this.rec].meta.push(BLACK);
this.update('BB'); this.update('BB');
} }
} }
@ -292,7 +293,7 @@ class Mscript {
this.dist = this.target - this.cam; this.dist = this.target - this.cam;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('BF'); this.arr.push('BF');
this.light.push(BLACK); this.meta.push(BLACK);
this.update('BF'); this.update('BF');
} }
} }
@ -300,7 +301,7 @@ class Mscript {
this.dist = this.cam - this.target; this.dist = this.cam - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('BB'); this.arr.push('BB');
this.light.push(BLACK); this.meta.push(BLACK);
this.update('BB'); this.update('BB');
} }
} }
@ -318,7 +319,7 @@ class Mscript {
this.dist = this.target - this.proj; this.dist = this.target - this.proj;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('PF'); this.loops[this.rec].arr.push('PF');
this.loops[this.rec].light.push(''); this.loops[this.rec].meta.push('');
this.update('PF'); this.update('PF');
} }
} }
@ -326,7 +327,7 @@ class Mscript {
this.dist = this.proj - this.target; this.dist = this.proj - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('PB'); this.loops[this.rec].arr.push('PB');
this.loops[this.rec].light.push(''); this.loops[this.rec].meta.push('');
this.update('PB'); this.update('PB');
} }
} }
@ -336,7 +337,7 @@ class Mscript {
this.dist = this.target - this.proj; this.dist = this.target - this.proj;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('PF'); this.arr.push('PF');
this.light.push(''); this.meta.push('');
this.update('PF'); this.update('PF');
} }
} }
@ -344,7 +345,7 @@ class Mscript {
this.dist = this.proj - this.target; this.dist = this.proj - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('PB'); this.arr.push('PB');
this.light.push(''); this.meta.push('');
this.update('PB'); this.update('PB');
} }
} }
@ -618,6 +619,13 @@ class Mscript {
const color = str.replace('L ', '').trim(); const color = str.replace('L ', '').trim();
this.color = color; this.color = color;
} }
/**
* Interpret a pause command
*
* @param {string} line String containing pause command
**/
pause(line) {
}
/** /**
* Throw an error with specific message * Throw an error with specific message
* *

File diff suppressed because one or more lines are too long

View File

@ -60,7 +60,7 @@ class Mscript {
this.rec = -1; this.rec = -1;
this.two = ''; this.two = '';
this.arr = []; this.arr = [];
this.light = []; this.meta = [];
this.target = 0; //move to target using CAM # or PROJ # this.target = 0; //move to target using CAM # or PROJ #
this.dist = 0; this.dist = 0;
this.variables = {}; this.variables = {};
@ -125,11 +125,12 @@ class Mscript {
else if (startsWith(line, 'ALERT')) { else if (startsWith(line, 'ALERT')) {
} }
else if (startsWith(line, 'PAUSE')) { else if (startsWith(line, 'PAUSE')) {
this.pause(line);
} }
} }
this.output.success = true; this.output.success = true;
this.output.arr = this.arr; //all instructions this.output.arr = this.arr; //all instructions
this.output.light = this.light; //all light instructions this.output.meta = this.meta; //all metadata for instructions
this.output.cam = this.cam; this.output.cam = this.cam;
this.output.proj = this.proj; this.output.proj = this.proj;
if (typeof callback !== 'undefined') { if (typeof callback !== 'undefined') {
@ -200,12 +201,12 @@ class Mscript {
//hold generated arr in state loop array //hold generated arr in state loop array
this.loops[this.rec].arr this.loops[this.rec].arr
.push.apply(this.loops[this.rec].arr, this.str_to_arr(line, this.two)); .push.apply(this.loops[this.rec].arr, this.str_to_arr(line, this.two));
this.loops[this.rec].light this.loops[this.rec].meta
.push.apply(this.loops[this.rec].light, this.light_to_arr(line, this.two)); .push.apply(this.loops[this.rec].meta, this.light_to_arr(line, this.two));
} }
else { else {
this.arr.push.apply(this.arr, this.str_to_arr(line, this.two)); this.arr.push.apply(this.arr, this.str_to_arr(line, this.two));
this.light.push.apply(this.light, this.light_to_arr(line, this.two)); this.meta.push.apply(this.meta, this.light_to_arr(line, this.two));
} }
} }
/** /**
@ -218,7 +219,7 @@ class Mscript {
this.rec++; this.rec++;
this.loops[this.rec] = { this.loops[this.rec] = {
arr: [], arr: [],
light: [], meta: [],
cam: 0, cam: 0,
proj: 0, proj: 0,
cmd: line + '' cmd: line + ''
@ -233,29 +234,29 @@ class Mscript {
* @param {string} line Line to interpret * @param {string} line Line to interpret
*/ */
end_loop(line) { end_loop(line) {
let light_arr; let meta_arr;
let start; let start;
let end; let end;
let len; let len;
for (let x = 0; x < this.loop_count(this.loops[this.rec].cmd); x++) { for (let x = 0; x < this.loop_count(this.loops[this.rec].cmd); x++) {
light_arr = this.loops[this.rec].light; meta_arr = this.loops[this.rec].meta;
if (this.loops[this.rec].fade) { if (this.loops[this.rec].fade) {
start = this.loops[this.rec].start; start = this.loops[this.rec].start;
end = this.loops[this.rec].end; end = this.loops[this.rec].end;
len = this.loops[this.rec].fade_len; len = this.loops[this.rec].fade_len;
light_arr = light_arr.map(l => { meta_arr = meta_arr.map(l => {
return this.fade_rgb(start, end, len, x); return this.fade_rgb(start, end, len, x);
}); });
} }
if (this.rec === 0) { if (this.rec === 0) {
this.arr.push.apply(this.arr, this.loops[this.rec].arr); this.arr.push.apply(this.arr, this.loops[this.rec].arr);
this.light.push.apply(this.light, light_arr); this.meta.push.apply(this.meta, meta_arr);
} }
else if (this.rec >= 1) { else if (this.rec >= 1) {
this.loops[this.rec - 1].arr this.loops[this.rec - 1].arr
.push.apply(this.loops[this.rec - 1].arr, this.loops[this.rec].arr); .push.apply(this.loops[this.rec - 1].arr, this.loops[this.rec].arr);
this.loops[this.rec - 1].light this.loops[this.rec - 1].meta
.push.apply(this.loops[this.rec - 1].light, light_arr); .push.apply(this.loops[this.rec - 1].meta, meta_arr);
} }
} }
this.update('END', this.loop_count(this.loops[this.rec].cmd)); this.update('END', this.loop_count(this.loops[this.rec].cmd));
@ -274,7 +275,7 @@ class Mscript {
this.dist = this.target - this.cam; this.dist = this.target - this.cam;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('BF'); this.loops[this.rec].arr.push('BF');
this.loops[this.rec].light.push(BLACK); this.loops[this.rec].meta.push(BLACK);
this.update('BF'); this.update('BF');
} }
} }
@ -282,7 +283,7 @@ class Mscript {
this.dist = this.cam - this.target; this.dist = this.cam - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('BB'); this.loops[this.rec].arr.push('BB');
this.loops[this.rec].light.push(BLACK); this.loops[this.rec].meta.push(BLACK);
this.update('BB'); this.update('BB');
} }
} }
@ -292,7 +293,7 @@ class Mscript {
this.dist = this.target - this.cam; this.dist = this.target - this.cam;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('BF'); this.arr.push('BF');
this.light.push(BLACK); this.meta.push(BLACK);
this.update('BF'); this.update('BF');
} }
} }
@ -300,7 +301,7 @@ class Mscript {
this.dist = this.cam - this.target; this.dist = this.cam - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('BB'); this.arr.push('BB');
this.light.push(BLACK); this.meta.push(BLACK);
this.update('BB'); this.update('BB');
} }
} }
@ -318,7 +319,7 @@ class Mscript {
this.dist = this.target - this.proj; this.dist = this.target - this.proj;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('PF'); this.loops[this.rec].arr.push('PF');
this.loops[this.rec].light.push(''); this.loops[this.rec].meta.push('');
this.update('PF'); this.update('PF');
} }
} }
@ -326,7 +327,7 @@ class Mscript {
this.dist = this.proj - this.target; this.dist = this.proj - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('PB'); this.loops[this.rec].arr.push('PB');
this.loops[this.rec].light.push(''); this.loops[this.rec].meta.push('');
this.update('PB'); this.update('PB');
} }
} }
@ -336,7 +337,7 @@ class Mscript {
this.dist = this.target - this.proj; this.dist = this.target - this.proj;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('PF'); this.arr.push('PF');
this.light.push(''); this.meta.push('');
this.update('PF'); this.update('PF');
} }
} }
@ -344,7 +345,7 @@ class Mscript {
this.dist = this.proj - this.target; this.dist = this.proj - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('PB'); this.arr.push('PB');
this.light.push(''); this.meta.push('');
this.update('PB'); this.update('PB');
} }
} }
@ -618,6 +619,13 @@ class Mscript {
const color = str.replace('L ', '').trim(); const color = str.replace('L ', '').trim();
this.color = color; this.color = color;
} }
/**
* Interpret a pause command
*
* @param {string} line String containing pause command
**/
pause(line) {
}
/** /**
* Throw an error with specific message * Throw an error with specific message
* *

File diff suppressed because one or more lines are too long

View File

@ -60,7 +60,7 @@ class Mscript {
rec : number; rec : number;
two : string; two : string;
arr : any[]; arr : any[];
light : string[]; meta : string[];
target : number; target : number;
dist : number; dist : number;
variables : any; variables : any;
@ -87,7 +87,7 @@ class Mscript {
this.two = ''; this.two = '';
this.arr = []; this.arr = [];
this.light = []; this.meta = [];
this.target = 0; //move to target using CAM # or PROJ # this.target = 0; //move to target using CAM # or PROJ #
this.dist = 0; this.dist = 0;
@ -148,13 +148,13 @@ class Mscript {
} else if (startsWith(line, 'ALERT')) { } else if (startsWith(line, 'ALERT')) {
} else if (startsWith(line, 'PAUSE')) { } else if (startsWith(line, 'PAUSE')) {
this.pause(line);
} }
} }
this.output.success = true; this.output.success = true;
this.output.arr = this.arr; //all instructions this.output.arr = this.arr; //all instructions
this.output.light = this.light; //all light instructions this.output.meta = this.meta; //all metadata for instructions
this.output.cam = this.cam; this.output.cam = this.cam;
this.output.proj = this.proj; this.output.proj = this.proj;
@ -232,13 +232,13 @@ class Mscript {
.push.apply(this.loops[this.rec].arr, .push.apply(this.loops[this.rec].arr,
this.str_to_arr(line, this.str_to_arr(line,
this.two)); this.two));
this.loops[this.rec].light this.loops[this.rec].meta
.push.apply(this.loops[this.rec].light, .push.apply(this.loops[this.rec].meta,
this.light_to_arr(line, this.light_to_arr(line,
this.two)); this.two));
} else { } else {
this.arr.push.apply(this.arr, this.str_to_arr(line, this.two)); this.arr.push.apply(this.arr, this.str_to_arr(line, this.two));
this.light.push.apply(this.light, this.light_to_arr(line, this.two)) this.meta.push.apply(this.meta, this.light_to_arr(line, this.two));
} }
} }
/** /**
@ -251,7 +251,7 @@ class Mscript {
this.rec++; this.rec++;
this.loops[this.rec] = { this.loops[this.rec] = {
arr : [], arr : [],
light : [], meta : [],
cam : 0, cam : 0,
proj : 0, proj : 0,
cmd : line + '' cmd : line + ''
@ -266,32 +266,32 @@ class Mscript {
* @param {string} line Line to interpret * @param {string} line Line to interpret
*/ */
end_loop (line : string) { end_loop (line : string) {
let light_arr : any[]; let meta_arr : string[];
let start : RGB; let start : RGB;
let end : RGB; let end : RGB;
let len : number; let len : number;
for (let x = 0; x < this.loop_count(this.loops[this.rec].cmd); x++) { for (let x = 0; x < this.loop_count(this.loops[this.rec].cmd); x++) {
light_arr = this.loops[this.rec].light; meta_arr = this.loops[this.rec].meta;
if (this.loops[this.rec].fade) { if (this.loops[this.rec].fade) {
start = this.loops[this.rec].start; start = this.loops[this.rec].start;
end = this.loops[this.rec].end; end = this.loops[this.rec].end;
len = this.loops[this.rec].fade_len; len = this.loops[this.rec].fade_len;
light_arr = light_arr.map(l => { meta_arr = meta_arr.map(l => {
return this.fade_rgb(start, end, len, x); return this.fade_rgb(start, end, len, x);
}) })
} }
if (this.rec === 0) { if (this.rec === 0) {
this.arr.push.apply(this.arr, this.loops[this.rec].arr); this.arr.push.apply(this.arr, this.loops[this.rec].arr);
this.light.push.apply(this.light, light_arr); this.meta.push.apply(this.meta, meta_arr);
} else if (this.rec >= 1) { } else if (this.rec >= 1) {
this.loops[this.rec - 1].arr this.loops[this.rec - 1].arr
.push.apply(this.loops[this.rec - 1].arr, .push.apply(this.loops[this.rec - 1].arr,
this.loops[this.rec].arr); this.loops[this.rec].arr);
this.loops[this.rec - 1].light this.loops[this.rec - 1].meta
.push.apply(this.loops[this.rec - 1].light, .push.apply(this.loops[this.rec - 1].meta,
light_arr); meta_arr);
} }
} }
this.update('END', this.loop_count(this.loops[this.rec].cmd)); this.update('END', this.loop_count(this.loops[this.rec].cmd));
@ -310,14 +310,14 @@ class Mscript {
this.dist = this.target - this.cam; this.dist = this.target - this.cam;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('BF'); this.loops[this.rec].arr.push('BF');
this.loops[this.rec].light.push(BLACK); this.loops[this.rec].meta.push(BLACK);
this.update('BF'); this.update('BF');
} }
} else { } else {
this.dist = this.cam - this.target; this.dist = this.cam - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('BB'); this.loops[this.rec].arr.push('BB');
this.loops[this.rec].light.push(BLACK); this.loops[this.rec].meta.push(BLACK);
this.update('BB'); this.update('BB');
} }
} }
@ -326,14 +326,14 @@ class Mscript {
this.dist = this.target - this.cam; this.dist = this.target - this.cam;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('BF'); this.arr.push('BF');
this.light.push(BLACK); this.meta.push(BLACK);
this.update('BF'); this.update('BF');
} }
} else { } else {
this.dist = this.cam - this.target; this.dist = this.cam - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('BB'); this.arr.push('BB');
this.light.push(BLACK); this.meta.push(BLACK);
this.update('BB'); this.update('BB');
} }
} }
@ -351,14 +351,14 @@ class Mscript {
this.dist = this.target - this.proj; this.dist = this.target - this.proj;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('PF'); this.loops[this.rec].arr.push('PF');
this.loops[this.rec].light.push(''); this.loops[this.rec].meta.push('');
this.update('PF'); this.update('PF');
} }
} else { } else {
this.dist = this.proj - this.target; this.dist = this.proj - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.loops[this.rec].arr.push('PB'); this.loops[this.rec].arr.push('PB');
this.loops[this.rec].light.push(''); this.loops[this.rec].meta.push('');
this.update('PB'); this.update('PB');
} }
} }
@ -367,14 +367,14 @@ class Mscript {
this.dist = this.target - this.proj; this.dist = this.target - this.proj;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('PF'); this.arr.push('PF');
this.light.push(''); this.meta.push('');
this.update('PF'); this.update('PF');
} }
} else { } else {
this.dist = this.proj - this.target; this.dist = this.proj - this.target;
for (let x = 0; x < this.dist; x++) { for (let x = 0; x < this.dist; x++) {
this.arr.push('PB'); this.arr.push('PB');
this.light.push(''); this.meta.push('');
this.update('PB'); this.update('PB');
} }
} }
@ -631,6 +631,15 @@ class Mscript {
this.color = color; this.color = color;
} }
/**
* Interpret a pause command
*
* @param {string} line String containing pause command
**/
pause (line : string) {
}
/** /**
* Throw an error with specific message * Throw an error with specific message
* *