Compare commits
No commits in common. "0eaefb2b48f9530e2b830f8e5e7222dd63c7e906" and "c365eff6a7ecad1f0ba9783e36122aca5d168446" have entirely different histories.
0eaefb2b48
...
c365eff6a7
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.8.138",
|
||||
"version": "1.8.136",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -510,8 +510,8 @@ class Mscript {
|
|||
* @param line {string} String containing set statement
|
||||
*/
|
||||
set_state(line) {
|
||||
//console.log(`set_state called: ${line}`);
|
||||
const update = {};
|
||||
let dist = 0;
|
||||
if (line.startsWith('SET CAM2')) {
|
||||
update.cam2 = parseInt(line.split('SET CAM2')[1]);
|
||||
}
|
||||
|
@ -530,14 +530,19 @@ class Mscript {
|
|||
else if (line.startsWith('SET PROJ')) {
|
||||
update.proj = parseInt(line.split('SET PROJ')[1]);
|
||||
}
|
||||
//console.log(JSON.stringify(update));
|
||||
if (this.rec > -1) {
|
||||
this.fail(`Line "${line}" is invalid inside of a loop`);
|
||||
return;
|
||||
for (let key of Object.keys(update)) {
|
||||
this.loops[this.rec][key] = update[key];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (let key of Object.keys(update)) {
|
||||
this[key] = update[key];
|
||||
}
|
||||
}
|
||||
console.dir(JSON.stringify(this));
|
||||
}
|
||||
/**
|
||||
* Return the last loop
|
||||
*
|
||||
|
@ -664,8 +669,7 @@ class Mscript {
|
|||
*/
|
||||
update(cmd, val = 1) {
|
||||
if (cmd === 'END') {
|
||||
//squashes down loops into the previous one until
|
||||
//the base is reached. val is never not 1, though.
|
||||
//I don't understand this loop
|
||||
for (let i = 0; i < val; i++) {
|
||||
if (this.rec === 0) {
|
||||
this.cam += this.loops[this.rec].cam;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -140,14 +140,7 @@ PF 1`;
|
|||
compile() {
|
||||
const data = this.editor.getValue();
|
||||
const mscript = new mscript_1.default();
|
||||
let output = null;
|
||||
try {
|
||||
output = mscript.interpret(data);
|
||||
}
|
||||
catch (err) {
|
||||
mse.console.print(err.toString());
|
||||
return;
|
||||
}
|
||||
const output = mscript.interpret(data);
|
||||
const len = output.arr.length;
|
||||
const cam2 = typeof output.cam2 !== 'undefined' ? `, CAM2 : ${output.cam2}` : '';
|
||||
const proj2 = typeof output.proj2 !== 'undefined' ? `, PROJ2 : ${output.proj2}` : '';
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy-app",
|
||||
"version": "1.8.138",
|
||||
"version": "1.8.136",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy-app",
|
||||
"version": "1.8.138",
|
||||
"version": "1.8.136",
|
||||
"description": "GUI for the mcopy small gauge film optical printer platform",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -162,14 +162,7 @@ PF 1`;
|
|||
compile () {
|
||||
const data : string = this.editor.getValue();
|
||||
const mscript : Mscript = new Mscript();
|
||||
let output : any = null;
|
||||
try {
|
||||
output = mscript.interpret(data);
|
||||
this.raw = '';
|
||||
} catch (err) {
|
||||
mse.console.print(err.toString());
|
||||
return;
|
||||
}
|
||||
const output : any = mscript.interpret(data);
|
||||
const len : number = output.arr.length;
|
||||
const cam2 : string = typeof output.cam2 !== 'undefined' ? `, CAM2 : ${output.cam2}` : '';
|
||||
const proj2 : string = typeof output.proj2 !== 'undefined' ? `, PROJ2 : ${output.proj2}` : '';
|
||||
|
|
|
@ -126,16 +126,12 @@ LOOP 10
|
|||
PF
|
||||
END`;
|
||||
|
||||
it('Should fail when SET state within LOOP', () => {
|
||||
let errorCaught = false;
|
||||
try {
|
||||
const obj = mscript.interpret(script2);
|
||||
} catch (err) {
|
||||
//fail silently
|
||||
errorCaught = true;
|
||||
}
|
||||
assert.ok(typeof obj === 'undefined', 'Mscript fails to produce an output object');
|
||||
assert.ok(errorCaught, 'Error should be thrown by script');
|
||||
it('Should SET state within LOOP', () => {
|
||||
const obj = mscript.interpret(script2)
|
||||
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
||||
assert.ok(obj.success, 'Mscript labeled output success');
|
||||
assert.equal(obj.cam, 10, 'Camera state ends at 10');
|
||||
assert.equal(obj.proj, 11, 'Projector state should be 11');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.8.138",
|
||||
"version": "1.8.136",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "mcopy",
|
||||
"version": "1.8.138",
|
||||
"version": "1.8.136",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mcopy",
|
||||
"version": "1.8.138",
|
||||
"version": "1.8.136",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"alert": "file:app/lib/alert",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy",
|
||||
"version": "1.8.138",
|
||||
"version": "1.8.136",
|
||||
"description": "Small gauge film optical printer platform",
|
||||
"main": "build.js",
|
||||
"directories": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.8.138",
|
||||
"version": "1.8.136",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -577,8 +577,8 @@ export default class Mscript {
|
|||
* @param line {string} String containing set statement
|
||||
*/
|
||||
private set_state (line : string) {
|
||||
//console.log(`set_state called: ${line}`);
|
||||
const update : MscriptUpdatedState = {};
|
||||
let dist : number = 0;
|
||||
if (line.startsWith('SET CAM2')) {
|
||||
update.cam2 = parseInt(line.split('SET CAM2')[1]);
|
||||
} else if (line.startsWith('SET CAMERA2')) {
|
||||
|
@ -592,14 +592,18 @@ export default class Mscript {
|
|||
} else if (line.startsWith('SET PROJ')) {
|
||||
update.proj = parseInt(line.split('SET PROJ')[1]);
|
||||
}
|
||||
//console.log(JSON.stringify(update));
|
||||
if (this.rec > -1) {
|
||||
this.fail(`Line "${line}" is invalid inside of a loop`);
|
||||
return;
|
||||
for (let key of Object.keys(update)) {
|
||||
(this.loops[this.rec] as any)[key] = (update as any)[key];
|
||||
}
|
||||
} else {
|
||||
for (let key of Object.keys(update)) {
|
||||
(this as any)[key] = (update as any)[key];
|
||||
}
|
||||
}
|
||||
console.dir(JSON.stringify(this));
|
||||
}
|
||||
/**
|
||||
* Return the last loop
|
||||
*
|
||||
|
@ -726,8 +730,7 @@ export default class Mscript {
|
|||
*/
|
||||
private update (cmd : string, val : number = 1) {
|
||||
if (cmd === 'END') {
|
||||
//squashes down loops into the previous one until
|
||||
//the base is reached. val is never not 1, though.
|
||||
//I don't understand this loop
|
||||
for (let i = 0; i < val; i++) {
|
||||
if (this.rec === 0) {
|
||||
this.cam += this.loops[this.rec].cam;
|
||||
|
|
Loading…
Reference in New Issue