Template:Team:Paris Saclay/simbox
From 2013.igem.org
(Difference between revisions)
Line 21: | Line 21: | ||
this.adjustable= false; | this.adjustable= false; | ||
this.history= new Array(); | this.history= new Array(); | ||
+ | } | ||
+ | |||
+ | function reaction() | ||
+ | { | ||
+ | this.inputs= new Array(); | ||
+ | this.outputs= new Array(); | ||
+ | this.probability= 0.0; | ||
} | } | ||
Line 28: | Line 35: | ||
this.volume= undefined; | this.volume= undefined; | ||
this.timestep= undefined; | this.timestep= undefined; | ||
- | this.molecules= Array(); | + | this.molecules= new Array(); |
+ | this.reactions= new Array(); | ||
this.running= false; | this.running= false; | ||
this.refresh_run_time= 50; | this.refresh_run_time= 50; | ||
this.refresh_interval= 100; | this.refresh_interval= 100; | ||
this.timeout= null; | this.timeout= null; | ||
+ | } | ||
+ | |||
+ | function simbox_get_molecule_id(simid, name) | ||
+ | { | ||
+ | for(var i= 0 ; i < simulations[simid].molecules.length ; ++i) | ||
+ | { | ||
+ | if(simulations[simid].molecules[i].name == name) | ||
+ | return i; | ||
+ | } | ||
+ | return null; | ||
} | } | ||
Line 86: | Line 104: | ||
simulations[id].molecules[i].adjustable= (molecule_tags[i].getAttribute('adjustable') == 'true'); | simulations[id].molecules[i].adjustable= (molecule_tags[i].getAttribute('adjustable') == 'true'); | ||
} | } | ||
+ | |||
+ | //Load reactions | ||
+ | var reaction_tags= xmldata.getElementsByTagName("reaction"); | ||
+ | for(var i= 0 ; i < reaction_tags.length ; ++i) | ||
+ | { | ||
+ | simulations[id].reactions[i]= new reaction(); | ||
+ | if(reaction_tags[i].hasAttribute('probability')) | ||
+ | simulations[id].reactions[i].probability= reaction_tags[i].getAttribute('probability'); | ||
+ | |||
+ | var input_tags= reaction_tags[i].getElementsByTagName("in"); | ||
+ | for(var j= 0 ; j < input_tags.length ; ++j) | ||
+ | { | ||
+ | var tmpid= simbox_get_molecule_id(id, input_tags[j].childNodes[0].nodeValue); | ||
+ | if(tmpid == null) | ||
+ | { | ||
+ | sb.innerHTML='Error : molecule "'+input_tags[j].childNodes[0].nodeValue+'" not defined.'; | ||
+ | return false; | ||
+ | } | ||
+ | simulations[id].reactions[i].inputs[j]= tmpid; | ||
+ | } | ||
+ | |||
+ | var output_tags= reaction_tags[i].getElementsByTagName("out"); | ||
+ | for(var j= 0 ; j < output_tags.length ; ++j) | ||
+ | { | ||
+ | var tmpid= simbox_get_molecule_id(id, output_tags[j].childNodes[0].nodeValue); | ||
+ | if(tmpid == null) | ||
+ | { | ||
+ | sb.innerHTML='Error : molecule "'+output_tags[j].childNodes[0].nodeValue+'" not defined.'; | ||
+ | return false; | ||
+ | } | ||
+ | simulations[id].reactions[i].outputs[j]= tmpid; | ||
+ | } | ||
+ | } | ||
+ | |||
//Create canvas | //Create canvas | ||
Line 212: | Line 264: | ||
function simulation_step(simid) | function simulation_step(simid) | ||
{ | { | ||
- | + | ||
} | } | ||
Revision as of 23:06, 2 August 2013