Skip to content

Instantly share code, notes, and snippets.

@PolGuixe
Created July 2, 2016 12:03
Show Gist options
  • Save PolGuixe/2d61453e13fa3831ecd7e9cb9e467421 to your computer and use it in GitHub Desktop.
Save PolGuixe/2d61453e13fa3831ecd7e9cb9e467421 to your computer and use it in GitHub Desktop.
modelling engine tests
import { Model, Block, InputBlock, OutputBlock, BlockDef, InputBlockDef, BlockDefParameter, Library } from 'meteor/zetoff:modelling-engine-entities';
import { Encoder, Decoder, Executer } from 'meteor/zetoff:modelling-engine-core';
const math = Library.get('math');
if (math) {
global.modelMath = new Model({
name: 'model_1',
libraries: [math],
});
const param_1 = new InputBlock({
name: 'param_1',
nickName: 'modelMath parameter 1',
blockDef: new InputBlockDef({
name: 'param_1_def',
nickName: 'modelMath parameter 1 definition',
output: [
new BlockDefParameter({
name: 'A',
nickName: 'A',
})
]
}),
});
param_1.output.A.value = 2;
modelMath.addBlock(param_1);
const sum_1 = new Block({
name: 'sum_1',
blockDef: math.getBlockDefByName('sum'),
});
// sum_1.input.A.value = 4;
sum_1.input.B.value = 3;
modelMath.addBlock(sum_1);
modelMath.addBlockRelation(param_1.output.A ,sum_1.input.A);
const sum_2 = new Block({
name: 'sum_2',
blockDef: math.getBlockDefByName('sum'),
});
sum_2.input.B.value = 8;
modelMath.addBlock(sum_2);
modelMath.addBlockRelation(sum_1.output.R, sum_2.input.A);
const acos_1 = new Block({
name: 'acos_1',
blockDef: math.getBlockDefByName('acos'),
});
acos_1.input.X.value = 0.5;
modelMath.addBlock(acos_1);
const div_int_1 = new OutputBlock({
name: 'div_int_1',
blockDef: math.getBlockDefByName('div_int'),
});
modelMath.addBlock(div_int_1);
modelMath.addBlockRelation(sum_2.output.R, div_int_1.input.A);
modelMath.addBlockRelation(acos_1.output.Y, div_int_1.input.B);
console.log(modelMath);
}
global.Engine = {
Library,
Model,
Block,
BlockDef,
Encoder,
Decoder,
Executer
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment