summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authoradhitya2016-04-07 20:15:52 +0000
committeradhitya2016-04-07 20:15:52 +0000
commit90dac8fcb85ec4d8c762a1c42ccebec3ebb864ff (patch)
tree98d464fa78c34c86ef3266773a89a7b4c595f904 /src/js
parenta2f0509a3179a408658e83f11ef7734f0c87240a (diff)
downloadxcos-on-web-90dac8fcb85ec4d8c762a1c42ccebec3ebb864ff.tar.gz
xcos-on-web-90dac8fcb85ec4d8c762a1c42ccebec3ebb864ff.tar.bz2
xcos-on-web-90dac8fcb85ec4d8c762a1c42ccebec3ebb864ff.zip
Test data added
Diffstat (limited to 'src/js')
-rw-r--r--src/js/xcos/core/details.js188
1 files changed, 188 insertions, 0 deletions
diff --git a/src/js/xcos/core/details.js b/src/js/xcos/core/details.js
new file mode 100644
index 0000000..437cf9d
--- /dev/null
+++ b/src/js/xcos/core/details.js
@@ -0,0 +1,188 @@
+// All arrays - separated by ',' or ';' or ' ' are taken to be 1 Dimensional
+// Only during printing, their nomenclature will change
+// Good read: http://javascript.info/tutorial/arguments#keyword-arguments
+
+function scicos_block() {
+ var options = arguments[0] || new Object();
+ this.graphics = options.graphics || new scicos_graphics();
+ this.model = options.model || new scicos_model();
+ this.gui = options.gui || '';
+ this.docs = options.docs || [];
+}
+
+function scicos_graphics() {
+ var options = arguments[0] || new Object();
+ this.orig = options.orig || [0, 0];
+ this.sz = options.sz || [80, 80]; // Space and comma works the same!
+ this.flip = options.flip || true;
+ this.theta = options.theta || 0;
+ this.exprs = options.exprs || [];
+ this.pin = options.pin || [];
+ this.pout = options.pout || [];
+ this.pein = options.pein || [];
+ this.peout = options.peout || [];
+ this.gr_i = options.gr_i || [];
+ this.id = options.id || '';
+ this.in_implicit = options.in_implicit || [];
+ this.out_implicit = options.out_implicit || ''; // There is only one!
+ this.in_style = options.in_style || [];
+ this.out_style = options.out_style || '';
+ this.in_label = options.in_label || [];
+ this.out_label = options.out_label || '';
+ this.style = options.style || '';
+}
+
+function scicos_model() {
+ var options = arguments[0] || new Object();
+ this.sim = options.sim || '';
+ this.in = options.in || [];
+ this.in2 = options.in2 || [];
+ this.intyp = options.intyp || [];
+ this.out = options.out || [];
+ this.out2 = options.out2 || [];
+ this.outtyp = options.outtyp || 1;
+ this.evtin = options.evtin || [];
+ this.evtout = options.evtout || [];
+ this.state = options.state || [];
+ this.dstate = options.dstate || [];
+ this.odstate = options.odstate || [];
+ this.ipar = options.ipar || [];
+ this.rpar = options.rpar || [];
+ this.opar = options.opar || [];
+ this.blocktype = options.blocktype || 'c';
+ this.firing = options.firing || [];
+ this.dep_ut = options.dep_ut || [false, false];
+ this.label = options.label || ''; // If label not available, use image
+ this.nzcross = options.nzcross || 0;
+ this.nmode = options.nmode || 0;
+ this.equations = options.equations || [];
+ this.uid = options.uid || '';
+}
+
+function scicos_diagram() {
+ this.props = new scicos_params();
+ this.objs = [];
+ this.version = '';
+ this.contrib = [];
+}
+
+function scicos_params() {
+ this.props = new scicos_params();
+ this.wpar = [600, 450, 0, 0, 600, 450];
+ this.titlex = 'Untitled';
+ this.tf = 100000;
+ this.tol = [Math.pow(10, -6), Math.pow(10, -6), Math.pow(10, -10), this.tf+1, 0, 1, 0];
+ this.context = [];
+ this.void1 = [];
+ this.options = new default_options();
+ this.void2 = [];
+ this.void3 = [];
+ this.doc = [];
+}
+
+function default_options() {
+ var options = new Object();
+ var col3d = [0.8, 0.8, 0.8];
+ options['3D'] = [true, 33];
+ options['Background'] = [8, 1]; // white,black
+ options['Link'] = [1, 5]; // black,red
+ options['ID'] = [[4, 1, 10, 1], [4, 1, 2, 1]];
+ options['Cmap'] = col3d;
+ return options;
+}
+
+function zeros(n){
+ return new Array(n+1).join('0').split('').map(parseFloat);
+}
+
+function standard_define() {
+ var sz = arguments[0];
+ var model = arguments[1];
+ var label = arguments[2];
+ var gr_i = arguments[3] || [];
+
+ var pin = [];
+ var pout = [];
+ var pein = [];
+ var peout = [];
+
+ var nin = model.in.length;
+ if(nin > 0){
+ pin = zeros(nin);
+ }
+ var nout = model.out.length;
+ if(nout > 0){
+ pout = zeros(nout);
+ }
+ var ncin = model.evtin.length;
+ if(ncin > 0){
+ pein = zeros(ncin);
+ }
+ var ncout = model.evtout.length;
+ if(ncout > 0){
+ peout = zeros(ncout);
+ }
+ gr_i = [gr_i, 8];
+ if(gr_i[1] == []){
+ gr_i[1] = 8;
+ }
+ if(gr_i[1] == 0){
+ gr_i[1] = [];
+ }
+ var graphics_options = {
+ sz: sz,
+ pin: pin,
+ pout: pout,
+ pein: pein,
+ peout: peout,
+ gr_i: gr_i,
+ exprs: label
+ };
+ var graphics = new scicos_graphics(graphics_options);
+ var block_options = {
+ graphics: graphics,
+ model: model,
+ gui: arguments.callee.caller.name
+ };
+ return new scicos_block(block_options);
+}
+
+function ANDLOG_f(){
+ var model = new scicos_model();
+ model.sim = "andlog";
+ model.out = [1];
+ model.out2 = [1];
+ model.evtin = [-1,-1];
+ model.blocktype = "d";
+ model.firing = [];
+ model.dep_ut = [false, false];
+ var gr_i = "xstringb(orig(1),orig(2),txt,sz(1),sz(2),'fill');";
+ var block = new standard_define([80,80], model, '', gr_i);
+ block.graphics.out_implicit = "E";
+ return block;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+