diff options
28 files changed, 353 insertions, 3454 deletions
diff --git a/views/script/gui.js b/views/script/gui.js index a18e6bc..e686d49 100644 --- a/views/script/gui.js +++ b/views/script/gui.js @@ -2,6 +2,10 @@ +str1="";
+str2="";
+str3="";
+final_str="";
globalVariable=0;
@@ -83,14 +87,14 @@ var webtronics={ showdefault:function(){
- {
+
webtronics.openProperties();
this.enablepage();
$('webtronics_properties_div').style.display = "none";
var elemnt=document.getElementById("webtronics_properties_ok");
elemnt.click();
webtronics.circuit.createvalue(webtronics.circuit.selected[0]);
- }
+
@@ -1506,14 +1510,14 @@ if($("webtronics_select"))Event.observe($('webtronics_select'), 'click', functio flag1=0;
+ saved_analysis_type=3;
- analysis_type=3;
jQuery("#analysis_selectbox").change(function(){
analysis_type = jQuery(this).val();
-
+ saved_analysis_type=analysis_type;
});
-
+ analysis_type=saved_analysis_type;
@@ -1553,17 +1557,16 @@ if($("webtronics_select"))Event.observe($('webtronics_select'), 'click', functio {
Flag = jQuery("#webtronics_netlist_text_area").val();
-
+jQuery("#webtronics_netlist_text_area").val("");
/*-------------------------------------------------------------------------------------------------------------------------------------
Here are the conditions concatenated to give final netlist values for dc all cases
---------------------------------------------------------------------------------------------------------------------------------------------*/
if (analysis_type == "1")
{
-// console.log(jQuery("#analysis_selectbox").val());
-
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".dc" + " " + source + " " + start + "e" + "-" + start_dc_unit + " " + stop + "e" + "-" + stop_dc_unit + " " + increment + "e" + "-" + increment_dc_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
-
+ str1='\n'+ ".dc" + " " + source + " " + start + "e" + "-" + start_dc_unit + " " + stop + "e" + "-" + stop_dc_unit + " " + increment + "e" + "-" + increment_dc_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n";
+ jQuery("#webtronics_netlist_text_area").val(Flag + str1 );
+ final_str=str1;
change_val = "1";
//console.log(jQuery("#analysis_selectbox").val());
}
@@ -1573,10 +1576,14 @@ if($("webtronics_select"))Event.observe($('webtronics_select'), 'click', functio Here are the all AC Cases for generating final netlist values
------------------------------------------------------------------------------------------------------------------------------------------------*/
else if (analysis_type == "2")
-{
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".ac" + " " + scale_val + " " + noofpoint + " " + startfreq + start_ac_unit + " " + stopfreq + stop_ac_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
+{
+ str2='\n'+ ".ac" + " " + scale_val + " " + noofpoint + " " + startfreq + start_ac_unit + " " + stopfreq + stop_ac_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" ;
+ jQuery("#webtronics_netlist_text_area").val(Flag +str2 );
+ final_str=str2;
change_val = "1";
+ //console.log(jQuery("#webtronics_netlist_text_area").val());
+ console.log("from 00");
}
/*------------------------------------------------------------------------------------------------------------------------------------------------
Here are the all Transiet Cases for generating final netlist values
@@ -1584,52 +1591,63 @@ Here are the all Transiet Cases for generating final netlist values //else if (analysis_type == "3" && time == "1")
else if (analysis_type== "3")
{
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n' + ".tran" + " " + step_trans + "e" + "-" + step_trans_unit + " " + stop_trans + "e"+ "-" + stop_trans_unit + " " + start_trans + "e" + "-" + start_trans_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n" +".end \n" );
-
+ str3='\n' + ".tran" + " " + step_trans + "e" + "-" + step_trans_unit + " " + stop_trans + "e"+ "-" + stop_trans_unit + " " + start_trans + "e" + "-" + start_trans_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n" +".end \n";
+ jQuery("#webtronics_netlist_text_area").val(Flag + str3 );
+ final_str=str3;
change_val = "1";
- }
-
-
-}
-else if( change_val == "1")
-{
+ }
- jQuery("#webtronics_netlist_text_area").val("");
- //console.log("if when 1")
+ console.log(jQuery("#webtronics_netlist_text_area").val());
+console.log("deepblueSea1");
- if (analysis_type == "1")
+}
- {
+else if (change_val == "1")
+ {
+jQuery("#webtronics_netlist_text_area").val("");
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".dc" + " " + source + " " + start + "e" + "-" + start_dc_unit + " " + stop + "e" + "-" + stop_dc_unit + " " + increment + "e" + "-" + increment_dc_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
- change_val = "1";
- }
+/*-------------------------------------------------------------------------------------------------------------------------------------
+ Here are the conditions concatenated to give final netlist values for dc all cases
+ ---------------------------------------------------------------------------------------------------------------------------------------------*/
+ if (analysis_type == "1")
+ {
+ jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".dc" + " " + source + " " + start + "e" + "-" + start_dc_unit + " " + stop + "e" + "-" + stop_dc_unit + " " + increment + "e" + "-" + increment_dc_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
+ change_val = "1";
+ //console.log(jQuery("#analysis_selectbox").val());
+}
- else if (analysis_type == "2")
- {
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".ac" + " " + scale_val + " " + noofpoint + " " + startfreq + start_ac_unit + " " + stopfreq + stop_ac_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
- change_val = "1";
- }
+/*------------------------------------------------------------------------------------------------------------------------------------------------
+Here are the all AC Cases for generating final netlist values
+------------------------------------------------------------------------------------------------------------------------------------------------*/
+else if (analysis_type == "2")
+{
+ jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".ac" + " " + scale_val + " " + noofpoint + " " + startfreq + start_ac_unit + " " + stopfreq + stop_ac_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
+ change_val = "1";
- else if (analysis_type == "3")
- {
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n' + ".tran" + " " + step_trans + "e" + "-" + step_trans_unit + " " + stop_trans + "e"+ "-" + stop_trans_unit + " " + start_trans + "e" + "-" + start_trans_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n" +".end \n" );
+}
+/*------------------------------------------------------------------------------------------------------------------------------------------------
+Here are the all Transiet Cases for generating final netlist values
+------------------------------------------------------------------------------------------------------------------------------------------------*/
+ //else if (analysis_type == "3" && time == "1")
+ else if (analysis_type== "3")
+ {
+ jQuery("#webtronics_netlist_text_area").val(Flag + '\n' + ".tran" + " " + step_trans + "e" + "-" + step_trans_unit + " " + stop_trans + "e"+ "-" + stop_trans_unit + " " + start_trans + "e" + "-" + start_trans_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n" +".end \n" );
- change_val = "1";
- }
+ change_val = "1";
}
+ console.log(jQuery("#webtronics_netlist_text_area").val());
-
-
+ console.log("deepblueSea");
+}
diff --git a/views/script/gui.js~ b/views/script/gui.js~ deleted file mode 100644 index 2493245..0000000 --- a/views/script/gui.js~ +++ /dev/null @@ -1,1526 +0,0 @@ -
-
-
-
-globalVariable=0;
-
-
-var webtronics={
- circuit:null,
- copy:null,
- rightclickmenu:null,
- title:null,
- description:null,
- file_id:null,
- scopestatus:null,
- scopedata:null,
-
- tabs:[],
- mode:'',
-
- Vlist:/\s*expression|\s*url|.*script/,
- Alist:/^(x|y|x1|y1|x2|y2|dx|dy|cx|cy|r|width|height|transform|d|id|class|fill|stroke|visibility|stroke-width|xmlns|xmlns:wtx|connects|partvalue|flippable|spice|index|font-size|font-weight|font-style|font-family)$/,
- Elist:/^(path|circle|rect|line|text|g|tspan|svg|wtx:eval1|wtx:eval2|wtx:eval3|wtx:eval4|wtx:eval5|wtx:eval6|wtx:pwlval1|wtx:pwlval2|wtx:pwlval3|wtx:pwlval4|wtx:pwlval5|wtx:pwlval6|wtx:pwlval7|wtx:pwlval8|wtx:pulval1|wtx:pulval2|wtx:pulval3|wtx:pulval4|wtx:pulval5|wtx:pulval6|wtx:pulval7|wtx:amplitude|wtx:phase|wtx:offsetvoltage|wtx:voltageamplitude|wtx:frequency|wtx:delaytime|wtx:dampingfactor|wtx:part|wtx:pins|wtx:analog|wtx:digital|wtx:node|wtx:id|wtx:type|wtx:name|wtx:category|wtx:value|wtx:label|wtx:spice|wtx:risedelay|wtx:inputload|wtx:falldelay|wtx:flip|wtx:model|wtx:measure|metadata|)$/,
- /* .lib files contain spice .model devices .mod devices contain .subckt devices and the id must begin with x*/
-// serverurls:["http://logical.github.io/webtronix/webtronix_server"],
- serverurls:["webtronix_server"],
- partslists:[],
- models:{},
- docfromtext:function(txt){
- var xmlDoc;
- if (window.DOMParser){
- parser=new DOMParser();
- xmlDoc=parser.parseFromString(txt,"text/xml");
-
- }
- else{ // Internet Explorer
- xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
- xmlDoc.async="false";
- xmlDoc.loadXML(txt);
- }
- return xmlDoc;
- },
-
-
- setsize:function(){
- var buffer=30;
- var realheight=window.innerHeight-$('webtronics_toolbar').offsetHeight-$('webtronics_footer').offsetHeight;
- var realwidth=window.innerWidth-$('webtronics_side_bar').offsetWidth;
- $('webtronics_center').style.width = window.offsetWidth+'px';
- $('webtronics_center').style.height = realheight-buffer+'px';
- $('webtronics_diagram_area').style.width = realwidth-buffer+'px';
- $('webtronics_diagram_area').style.height = realheight-buffer+'px';
- frames=$$('#webtronics_diagram_area>iframe')
- if(frames[0])frames[0].width = realwidth-buffer+'px';
- $('webtronics_side_bar').style.height=realheight-buffer+'px';
- },
-
-
-
- setMode:function(mode, status){
-
-
- //$('webtronics_status_bar').innerHTML = 'Mode: '+status;
- $('webtronics_add_text').style.display='none';
- if(mode=='select'){
- if($('webtronics_context_menu'))$('webtronics_context_menu').style.display='block';
- }
- else if(mode=='line'){
- if($('webtronics_context_menu'))$('webtronics_context_menu').style.display='none';
- if(this.circuit.selected){
- this.circuit.unselect();
- }
- }
- else if(mode=='text'){
- if($('webtronics_context_menu'))$('webtronics_context_menu').style.display='none';
- }
- $('webtronics_context_menu').style.display='none';
- this.circuit.mode=mode;
-
-},
-
-
-getvalues:function(elem){
-
-
- $("webtronics_part_model").options.length=0;
- $("webtronics_part_dir_model").options.length=0;
- $("webtronics_part_model").appendChild(new Element("option",{"value":""}).update("none"));
- $("webtronics_part_dir_model").appendChild(new Element("option",{"value":""}).update("none"));
- var part=netlistcreator.readwtx(elem,"name");
- var cat=netlistcreator.readwtx(elem,"category");
- if(cat && (part != "model")){
- for(var i=0;i<webtronics.partslists.length;i++){
- if(webtronics.partslists[i].parts[cat][part].values!=undefined){
- for(var model in webtronics.partslists[i].parts[cat][part].values){
- console.log("model");
- $("webtronics_part_model").insert(new Element("option",{"value":model}).update(model));
- }
- if(JSON.stringify(list).indexOf(part)!=-1){
- $("webtronics_part_help").innerHTML=webtronics.partslists[i].parts[cat][part].help;
- }
- }
-}
-}
-},
-
-center:function(e){
-
- e.style.left = ($('webtronics_main_window').offsetWidth/2)-(e.offsetWidth/2)+'px';
- e.style.top = ($('webtronics_main_window').offsetHeight/2)-(e.offsetHeight/2)+'px';
-},
-
-disablepage:function(){
- $("webtronics_disable").style.display="block";
-},
-enablepage:function(){
- $("webtronics_disable").style.display="none";
-},
-
-returnchip:function(){
- if($('webtronics_chip_display').getElementsByTagName('g').length){
- this.circuit.getgroup($('webtronics_chip_display').getElementsByTagName('g')[0]);
- netlistcreator.writewtx(this.circuit.selected[0],"id",this.circuit.getnextid(this.circuit.selected[0],0));
- this.circuit.createvalue(this.circuit.selected[0]);
- }
- $('webtronics_chips_box').style.display='none';
- this.setMode('select','Selection');
-},
-
-openProperties:function(){
- document.forms['webtronics_properties_form'].reset();
- var c=netlistcreator.readwtx(this.circuit.selected[0],"name");
- $("webtronics_risedelay").style.display='none';
- $("webtronics_falldelay").style.display='none';
- $("webtronics_inputload").style.display='none';
- if(!c){
- netlistcreator.writewtx(this.circuit.selected[0],"name","ic");
- }
- if(c=="ac"){
- this.getvalues(this.circuit.selected[0]);
- $("webtronics_amplitude").style.display='block'
- $("webtronics_phase").style.display='block'
-
- var amplitude=netlistcreator.readwtx(this.circuit.selected[0],"amplitude");
- var phase=netlistcreator.readwtx(this.circuit.selected[0],"phase");
-
- if(amplitude!=""){
- $('webtronics_amplitude_value').value=amplitude;
- //jQuery("#webtronics_amplitude_value").val()=amplitude;
- }
-
- if(phase!=""){$('webtronics_phase_value').value=phase;}
-
-
- $("webtronics_eval1").style.display='none'
- $("webtronics_eval2").style.display='none'
- $("webtronics_eval3").style.display='none'
- $("webtronics_eval4").style.display='none'
- $("webtronics_eval5").style.display='none'
- $("webtronics_eval6").style.display='none'
-
-
- $("webtronics_pwlval1").style.display='none'
- $("webtronics_pwlval2").style.display='none'
- $("webtronics_pwlval3").style.display='none'
- $("webtronics_pwlval4").style.display='none'
- $("webtronics_pwlval5").style.display='none'
- $("webtronics_pwlval6").style.display='none'
- $("webtronics_pwlval7").style.display='none'
- $("webtronics_pwlval8").style.display='none'
-
-
- $("webtronics_offsetvoltage").style.display='none'
- $("webtronics_frequency").style.display='none'
- $("webtronics_voltageamplitude").style.display='none'
- $("webtronics_delaytime").style.display='none'
- $("webtronics_dampingfactor").style.display='none'
- $("directive").style.display='none'
-
-
- $("webtronics_pulval1").style.display='none'
- $("webtronics_pulval2").style.display='none'
- $("webtronics_pulval3").style.display='none'
- $("webtronics_pulval4").style.display='none'
- $("webtronics_pulval5").style.display='none'
- $("webtronics_pulval6").style.display='none'
- $("webtronics_pulval7").style.display='none'
-
-
- $("valuemodel").style.display='none'
-
- $("webtronics_print_dir_field").style.display='block'
- $("webtronics_print_dir_value").value=netlistcreator.readwtx(this.circuit.selected[0],'measure');
- }
-
-
-
- else if(c=="sinvoltagesource"){
- $("webtronics_amplitude").style.display='none'
- $("webtronics_phase").style.display='none'
-
-
- $("webtronics_eval1").style.display='none'
- $("webtronics_eval2").style.display='none'
- $("webtronics_eval3").style.display='none'
- $("webtronics_eval4").style.display='none'
- $("webtronics_eval5").style.display='none'
- $("webtronics_eval6").style.display='none'
-
-
- $("webtronics_offsetvoltage").style.display='block'
- $("webtronics_frequency").style.display='block'
- $("webtronics_voltageamplitude").style.display='block'
- $("webtronics_delaytime").style.display='block'
- $("webtronics_dampingfactor").style.display='block'
- $("directive").style.display='none'
-
-
- $("webtronics_pwlval1").style.display='none'
- $("webtronics_pwlval2").style.display='none'
- $("webtronics_pwlval3").style.display='none'
- $("webtronics_pwlval4").style.display='none'
- $("webtronics_pwlval5").style.display='none'
- $("webtronics_pwlval6").style.display='none'
- $("webtronics_pwlval7").style.display='none'
- $("webtronics_pwlval8").style.display='none'
-
-
- $("webtronics_pulval1").style.display='none'
- $("webtronics_pulval2").style.display='none'
- $("webtronics_pulval3").style.display='none'
- $("webtronics_pulval4").style.display='none'
- $("webtronics_pulval5").style.display='none'
- $("webtronics_pulval6").style.display='none'
- $("webtronics_pulval7").style.display='none'
-
-
- var offsetvoltage=netlistcreator.readwtx(this.circuit.selected[0],"offsetvoltage");
- var voltageamplitude=netlistcreator.readwtx(this.circuit.selected[0],"voltageamplitude");
- var frequency=netlistcreator.readwtx(this.circuit.selected[0],"frequency");
- var delaytime=netlistcreator.readwtx(this.circuit.selected[0],"delaytime");
- var dampingfactor=netlistcreator.readwtx(this.circuit.selected[0],"dampingfactor");
-
- if(offsetvoltage!=""){$('webtronics_offsetvoltage_value').value=offsetvoltage;}
- if(voltageamplitude!=""){$('webtronics_voltageamplitude_value').value=voltageamplitude;}
- if(frequency!=""){$('webtronics_frequency_value').value=frequency;}
- if(delaytime!=""){$('webtronics_delaytime_value').value=delaytime;}
- if(dampingfactor!=""){$('webtronics_dampingfactor_value').value=dampingfactor;}
-
-
- $("valuemodel").style.display='none'
- }
-
-
- else if(c=="pulse"){
- $("webtronics_amplitude").style.display='none'
- $("webtronics_phase").style.display='none'
-
- $("webtronics_offsetvoltage").style.display='none'
- $("webtronics_frequency").style.display='none'
- $("webtronics_voltageamplitude").style.display='none'
- $("webtronics_delaytime").style.display='none'
- $("webtronics_dampingfactor").style.display='none'
-
-
- $("webtronics_eval1").style.display='none'
- $("webtronics_eval2").style.display='none'
- $("webtronics_eval3").style.display='none'
- $("webtronics_eval4").style.display='none'
- $("webtronics_eval5").style.display='none'
- $("webtronics_eval6").style.display='none'
-
-
-
- $("webtronics_pwlval1").style.display='none'
- $("webtronics_pwlval2").style.display='none'
- $("webtronics_pwlval3").style.display='none'
- $("webtronics_pwlval4").style.display='none'
- $("webtronics_pwlval5").style.display='none'
- $("webtronics_pwlval6").style.display='none'
- $("webtronics_pwlval7").style.display='none'
- $("webtronics_pwlval8").style.display='none'
-
- $("webtronics_pulval1").style.display='block'
- $("webtronics_pulval2").style.display='block'
- $("webtronics_pulval3").style.display='block'
- $("webtronics_pulval4").style.display='block'
- $("webtronics_pulval5").style.display='block'
- $("webtronics_pulval6").style.display='block'
- $("webtronics_pulval7").style.display='block'
-
- $("directive").style.display='none'
- var pulval1=netlistcreator.readwtx(this.circuit.selected[0],"pulval1");
- var pulval2=netlistcreator.readwtx(this.circuit.selected[0],"pulval2");
- var pulval3=netlistcreator.readwtx(this.circuit.selected[0],"pulval3");
- var pulval4=netlistcreator.readwtx(this.circuit.selected[0],"pulval4");
- var pulval5=netlistcreator.readwtx(this.circuit.selected[0],"pulval5");
- var pulval6=netlistcreator.readwtx(this.circuit.selected[0],"pulval6");
- var pulval7=netlistcreator.readwtx(this.circuit.selected[0],"pulval7");
- if(pulval1!=""){$('webtronics_pulval1_value').value=pulval1;}
- if(pulval2!=""){$('webtronics_pulval2_value').value=pulval2;}
- if(pulval3!=""){$('webtronics_pulval3_value').value=pulval3;}
- if(pulval4!=""){$('webtronics_pulval4_value').value=pulval4;}
- if(pulval5!=""){$('webtronics_pulval5_value').value=pulval5;}
- if(pulval6!=""){$('webtronics_pulval6_value').value=pulval6;}
- if(pulval7!=""){$('webtronics_pulval7_value').value=pulval7;}
-
- $("valuemodel").style.display='none'
- }
-
- else if(c=="exponential"){
- $("webtronics_amplitude").style.display='none'
- $("webtronics_phase").style.display='none'
-
- $("webtronics_offsetvoltage").style.display='none'
- $("webtronics_frequency").style.display='none'
- $("webtronics_voltageamplitude").style.display='none'
- $("webtronics_delaytime").style.display='none'
- $("webtronics_dampingfactor").style.display='none'
-
-
- $("webtronics_pulval1").style.display='none'
- $("webtronics_pulval2").style.display='none'
- $("webtronics_pulval3").style.display='none'
- $("webtronics_pulval4").style.display='none'
- $("webtronics_pulval5").style.display='none'
- $("webtronics_pulval6").style.display='none'
- $("webtronics_pulval7").style.display='none'
-
-
- $("webtronics_pwlval1").style.display='none'
- $("webtronics_pwlval2").style.display='none'
- $("webtronics_pwlval3").style.display='none'
- $("webtronics_pwlval4").style.display='none'
- $("webtronics_pwlval5").style.display='none'
- $("webtronics_pwlval6").style.display='none'
- $("webtronics_pwlval7").style.display='none'
- $("webtronics_pwlval8").style.display='none'
-
- $("webtronics_eval1").style.display='block'
- $("webtronics_eval2").style.display='block'
- $("webtronics_eval3").style.display='block'
- $("webtronics_eval4").style.display='block'
- $("webtronics_eval5").style.display='block'
- $("webtronics_eval6").style.display='block'
-
-
- $("directive").style.display='none'
- var eval1=netlistcreator.readwtx(this.circuit.selected[0],"eval1");
- var eval2=netlistcreator.readwtx(this.circuit.selected[0],"eval2");
- var eval4=netlistcreator.readwtx(this.circuit.selected[0],"eval4");
- var eval3=netlistcreator.readwtx(this.circuit.selected[0],"eval3");
- var eval5=netlistcreator.readwtx(this.circuit.selected[0],"eval5");
- var eval6=netlistcreator.readwtx(this.circuit.selected[0],"eval6");
-
- if(eval1!=""){$('webtronics_eval1_value').value=eval1;}
- if(eval2!=""){$('webtronics_eval2_value').value=eval2;}
- if(eval3!=""){$('webtronics_eval3_value').value=eval3;}
- if(eval4!=""){$('webtronics_eval4_value').value=eval4;}
- if(eval5!=""){$('webtronics_eval5_value').value=eval5;}
- if(eval6!=""){$('webtronics_eval6_value').value=eval6;}
-
-
- $("valuemodel").style.display='none'
- }
-
-
-
-
- else if(c=="pwl"){
- $("webtronics_amplitude").style.display='none'
- $("webtronics_phase").style.display='none'
-
- $("webtronics_offsetvoltage").style.display='none'
- $("webtronics_frequency").style.display='none'
- $("webtronics_voltageamplitude").style.display='none'
- $("webtronics_delaytime").style.display='none'
- $("webtronics_dampingfactor").style.display='none'
-
-
-
- $("webtronics_eval1").style.display='none'
- $("webtronics_eval2").style.display='none'
- $("webtronics_eval3").style.display='none'
- $("webtronics_eval4").style.display='none'
- $("webtronics_eval5").style.display='none'
- $("webtronics_eval6").style.display='none'
-
- $("webtronics_pulval1").style.display='none'
- $("webtronics_pulval2").style.display='none'
- $("webtronics_pulval3").style.display='none'
- $("webtronics_pulval4").style.display='none'
- $("webtronics_pulval5").style.display='none'
- $("webtronics_pulval6").style.display='none'
- $("webtronics_pulval7").style.display='none'
-
-
- $("webtronics_pwlval1").style.display='block'
- $("webtronics_pwlval2").style.display='block'
- $("webtronics_pwlval3").style.display='block'
- $("webtronics_pwlval4").style.display='block'
- $("webtronics_pwlval5").style.display='block'
- $("webtronics_pwlval6").style.display='block'
- $("webtronics_pwlval7").style.display='block'
- $("webtronics_pwlval8").style.display='block'
-
- $("directive").style.display='none'
- var pwlval1=netlistcreator.readwtx(this.circuit.selected[0],"pwlval1");
- var pwlval2=netlistcreator.readwtx(this.circuit.selected[0],"pwlval2");
- var pwlval3=netlistcreator.readwtx(this.circuit.selected[0],"pwlval3");
- var pwlval4=netlistcreator.readwtx(this.circuit.selected[0],"pwlval4");
- var pwlval5=netlistcreator.readwtx(this.circuit.selected[0],"pwlval5");
- var pwlval6=netlistcreator.readwtx(this.circuit.selected[0],"pwlval6");
- var pwlval7=netlistcreator.readwtx(this.circuit.selected[0],"pwlval7");
- var pwlval8=netlistcreator.readwtx(this.circuit.selected[0],"pwlval8");
- if(pwlval1!=""){$('webtronics_pwlval1_value').value=pwlval1;}
- if(pwlval2!=""){$('webtronics_pwlval2_value').value=pwlval2;}
- if(pwlval3!=""){$('webtronics_pwlval3_value').value=pwlval3;}
- if(pwlval4!=""){$('webtronics_pwlval4_value').value=pwlval4;}
- if(pwlval5!=""){$('webtronics_pwlval5_value').value=pwlval5;}
- if(pwlval6!=""){$('webtronics_pwlval6_value').value=pwlval6;}
- if(pwlval7!=""){$('webtronics_pwlval7_value').value=pwlval7;}
- if(pwlval8!=""){$('webtronics_pwlval7_value').value=pwlval8;}
-
- $("valuemodel").style.display='none'
- }
-
-
-
-
-
-
- else if(c=="scope"){
- this.getvalues(this.circuit.selected[0]);
- $("webtronics_print_dir_field").style.display='block'
- $("webtronics_print_dir_value").value=netlistcreator.readwtx(this.circuit.selected[0],'measure');
- $("directive").style.display='none'
-
- $("webtronics_offsetvoltage").style.display='none'
- $("webtronics_frequency").style.display='none'
- $("webtronics_voltageamplitude").style.display='none'
- $("webtronics_delaytime").style.display='none'
- $("webtronics_dampingfactor").style.display='none'
-
-
- $("webtronics_eval1").style.display='none'
- $("webtronics_eval2").style.display='none'
- $("webtronics_eval3").style.display='none'
- $("webtronics_eval4").style.display='none'
- $("webtronics_eval5").style.display='none'
- $("webtronics_eval6").style.display='none'
-
-
- $("webtronics_pwlval1").style.display='none'
- $("webtronics_pwlval2").style.display='none'
- $("webtronics_pwlval3").style.display='none'
- $("webtronics_pwlval4").style.display='none'
- $("webtronics_pwlval5").style.display='none'
- $("webtronics_pwlval6").style.display='none'
- $("webtronics_pwlval7").style.display='none'
- $("webtronics_pwlval8").style.display='none'
-
- $("webtronics_pulval1").style.display='none'
- $("webtronics_pulval2").style.display='none'
- $("webtronics_pulval3").style.display='none'
- $("webtronics_pulval4").style.display='none'
- $("webtronics_pulval5").style.display='none'
- $("webtronics_pulval6").style.display='none'
- $("webtronics_pulval7").style.display='none'
-
- $("webtronics_amplitude").style.display='none'
- $("webtronics_phase").style.display='none'
- }
- else {
- this.getvalues(this.circuit.selected[0]);
- $("directive").style.display='none'
-
- $("webtronics_offsetvoltage").style.display='none'
- $("webtronics_frequency").style.display='none'
- $("webtronics_voltageamplitude").style.display='none'
- $("webtronics_delaytime").style.display='none'
- $("webtronics_dampingfactor").style.display='none'
- $("valuemodel").style.display='block'
-
- $("webtronics_amplitude").style.display='none'
- $("webtronics_phase").style.display='none'
-
-
- $("webtronics_eval1").style.display='none'
- $("webtronics_eval2").style.display='none'
- $("webtronics_eval3").style.display='none'
- $("webtronics_eval4").style.display='none'
- $("webtronics_eval5").style.display='none'
- $("webtronics_eval6").style.display='none'
-
-
- $("webtronics_pwlval1").style.display='none'
- $("webtronics_pwlval2").style.display='none'
- $("webtronics_pwlval3").style.display='none'
- $("webtronics_pwlval4").style.display='none'
- $("webtronics_pwlval5").style.display='none'
- $("webtronics_pwlval6").style.display='none'
- $("webtronics_pwlval7").style.display='none'
- $("webtronics_pwlval8").style.display='none'
-
-
- $("webtronics_pulval1").style.display='none'
- $("webtronics_pulval2").style.display='none'
- $("webtronics_pulval3").style.display='none'
- $("webtronics_pulval4").style.display='none'
- $("webtronics_pulval5").style.display='none'
- $("webtronics_pulval6").style.display='none'
- $("webtronics_pulval7").style.display='none'
- var value=netlistcreator.readwtx(this.circuit.selected[0],"value");
- if(value!=""){$('webtronics_part_value').value=value;}
-
- if(c=='and'|| c=='not'|| c=='nand'|| c=='or'||c=='nor'||c=='xor'||c=='xnor')
- {
-
- $("webtronics_risedelay").style.display='block';
- $("webtronics_falldelay").style.display='block';
- $("webtronics_inputload").style.display='block';
- var risedelay = netlistcreator.readwtx(this.circuit.selected[0],"risedelay");
- if(risedelay!=""){$(webtronics_part_risedelay).value=risedelay;}
- var falldelay = netlistcreator.readwtx(this.circuit.selected[0],"falldelay");
- if(falldelay!=""){$(webtronics_part_falldelay).value=falldelay;}
- var inputload = netlistcreator.readwtx(this.circuit.selected[0],"inputload");
- if(inputload!=""){$(webtronics_part_inputload).value=inputload;}
-
- }
-
- }
-
- if(c=="diode")$("directive").style.display='block'
- var id=netlistcreator.readwtx(this.circuit.selected[0],"id");
-
-
- if(id!=""){$('webtronics_part_id').value=id;}
-
- $("webtronics_part_dir_value").value=netlistcreator.readwtx(this.circuit.selected[0],'model');
-
- if(!netlistcreator.readwtx(webtronics.circuit.selected[0],"value")){
- $('webtronics_part_id').value=this.circuit.getnextid(this.circuit.selected[0],0);
- }
-
- this.disablepage();
- $('webtronics_properties_div').style.display = "block";
-
-},
-
-sanitize:function(xmldoc){
- var elems=xmldoc.getElementsByTagName('*');
- for(var i=0;i<elems.length;i++){
- if(!elems[i].tagName.match(this.Elist))return elems[i].tagName;
- var attr=elems[i].attributes;
- for(var j=0;j<attr.length;j++){
- if(!attr[j].name.match(this.Alist))return attr[j].name;
- if(attr[j].value.match(this.Vlist))return attr[j].value;
- }
- }
-},
-createfilemenu:function(x,y,id,parent,list){
- var menu=document.createElement('div');
- menu.id=id;
- menu.className='webtronics_menu';
- menu.style.left=x+'px';
- menu.style.top=y+'px';
- for(var i=0;i<list.length;i++){
- var item=new Element('a',{Title:list[i].label,id:'webtronics_context_option',class:'enabled'})
- .observe('click',list[i].cb.bind(this))
- .observe('contextmenu', Event.stop)
- .update(list[i].label);
- menu.insert(item);
- menu.insert(new Element('br'));
- }
- menu.observe('click',Event.stop)
- .observe('contextmenu',Event.stop);
- menu.style.display='none';
- return menu;
-
-},
-
-file_open:function(){
- var file=new Element('input',{'type':'file'});
- var div=new Element('div',{'class':'modal'}).insert(file);
- Event.observe(file,'change',function(){
- if(window.FileReader){
- var textReader = new FileReader();
- textReader.onloadend=function(){
- if(!textReader.result){
- console.log("error opening file");
- return;
- };
-
- var xmlDoc=this.docfromtext(textReader.result);
- if(!xmlDoc){alert("error parsing svg");}
- else{
- var result=this.sanitize(xmlDoc)
- if(result){console.log(result+ ' found');alert('unclean file');return;}
- var node=xmlDoc.getElementsByTagName('svg')[0];
- if(!node){alert("svg node not found")}
- else this.circuit.getfile(node);
- }
- }.bind(this);
- textReader.readAsText(file.files[0]);
- $('webtronics_main_window').removeChild(div);
- }
- }.bind(this));
- $('webtronics_main_window').insert(div);
- div.style.display='block';
- file.focus();
- file.click();
- $('webtronics_file_menu').style.display='none';
- div.style.display='none';
-
-},
-
-download:function(filename, data) {
- var pom = document.createElement('a');
- pom.setAttribute('href', data);
- pom.setAttribute('download', filename);
- document.body.appendChild(pom);
- pom.click();
- pom.parentNode.removeChild(pom);
-},
-saveuri:function(){
- var string="<?xml version='1.0' ?>\n";
- string+="<!--Created by webtronics 0.1-->\n";
- var doc=this.circuit.getDoc(true,false);
- string += (new XMLSerializer()).serializeToString(doc);
- this.download("webtronix.svg","data:application/octet-stream;charset=utf-8;base64," + encode64(string));
-
- $('webtronics_file_menu').style.display='none';
-
-},
-
-
-
-
-file_new:function(){
- $('webtronics_file_menu').style.display='none';
- //this.setMode('webtronics_select','select','Selection');
- input_box=confirm("Click OK to Clear the Drawing.");
- if (input_box==true){
- $('webtronics_diagram_area').removeChild($("webtronics_display_frame"));
- var frame=new Element('iframe',{id:'webtronics_display_frame',src:'canvas/canvas.html'});
- $('webtronics_diagram_area').insert(frame);
- Event.observe(frame,'load',function(){
- var filename='Schematic.svg';
- this.attachframe(filename,frame);
-
- }.bind(this));
- $("webtronics_showhelp").checked=false;
- $$(".webtronics_help").forEach(function(e){
- e.style.display="none";
- });
- $("webtronics_invert").checked=false;
- $("webtronics_graph").checked=false;
- $("webtronics_connections").checked=false;
-
- }
- },
-
- attachframe:function(filename,frame){
- this.circuit=frame.contentWindow.circuit;
- this.setMode('select', 'Selection');
- // this.circuit.mode=this.mode;
-
- /*attach the menu*/
- Event.observe(this.circuit.container,'contextmenu',function(e){
- $('webtronics_context_menu').style.top=Event.pointerY(e)+'px';
- $('webtronics_context_menu').style.left=Event.pointerX(e)+'px';
- if(this.circuit.mode =="select")$('webtronics_context_menu').style.display='block';
- if(this.circuit.selected.length===1&& this.circuit.selected[0].tagName==='g'){
- $$('div#webtronics_context_menu [title=Properties]')[0].className='enabled';
- }
- else {
- $$('div#webtronics_context_menu [title=Properties]')[0].className='disabled';
- }
- Event.stop(e);
- }.bind(this));
- Event.observe(this.circuit.container,'click',function(e){
- if(Event.isLeftClick(e)){
- if($('webtronics_context_menu')){
- $('webtronics_context_menu').style.display='none';
- }
- }
- }.bind(this));
-
-
- },
-
- formatnetlist:function(spice1,spice2){
- var html=new Element('textarea');
- html.id="webtronics_netlist_text_area";
- html.cols=40;
- html.rows=15;
- html.value=spice1;
- return html;
- },
- spicenetlist:"",
- gnucapjs:function(netlist){
- webtronics.spicenetlist=netlist;
- /*add a new frame */
- $('webtronics_scope_display_div').innerHTML='';
- $("webtronics_scope_output_graph").checked=true;
- $("webtronics_scope_status").innerHTML="DOWNLOADING GNUCAP";
-
- var frame=new Element('iframe',{id:'webtronics_scope_display_frame',src:'gnucapjs/gnucap.html',width:"100%",height:"100%"});
- $('webtronics_scope_display_div').insert(frame);
- $("webtronics_scope_display").style.display="block"
- },
-
- /*
- * postspice:function(spice){
- * var text;
- * new Ajax.Request("spice.php",{
- * method:'post',
- * contentType:"text/plain",
- * asynchronous:true,
- * postBody:spice,
- * onSuccess:function(transport){
- * if($("webtronics_scope_display_image"))$("webtronics_scope_display_image").parentNode.removeChild($("webtronics_scope_display_image"));
- * var content;
- * if(transport.responseText.match("data:image/png;base64,")){
- * var content=new Element("img",{"src":transport.responseText,"width":400,"height":400,"id":"webtronics_scope_display_image"});
-}
-else{
- var content=new Element("textarea",{"width":400,"height":400,"id":"webtronics_scope_display_image"}).update(transport.responseText);
-}
-if(content){
- $("webtronics_scope_display").style.display="block";
- $("webtronics_scope_display_div").insert(content);
-}
-},
-onFailure: function(){
-console.log('Could not retrieve file...');
-},
-onException: function(req,exception) {
-console.log(exception);
-}
-});
-
-},
-*/
-savepng:function(){
-/*
- if(navigator.appName == 'Microsoft Internet Explorer'){
- $('webtronics_image_div').innerHTML="<img id='webtronics_image_save' >";
- }
- */
- if(this.circuit.drawing.getAttribute('class')==="inv"){
- var doc=this.circuit.getDoc(true,true);
- }
- else{
- var doc=this.circuit.getDoc(true,false);
- }
- var svgsize=this.circuit.svgSize();
- var canvas=new Element('canvas',{'id':'webtronics_canvas','width':svgsize.width-svgsize.x+20+'px','height':svgsize.height-svgsize.y+20+'px',style:"display:none"});
- document.body.insert(canvas);
- var ctx=$("webtronics_canvas").getContext("2d");
-
- ctx.drawSvg(doc, 0, 0, svgsize.width-svgsize.x+20,svgsize.height-svgsize.y+20);
- var url= canvas.toDataURL("application/octet-stream");
- this.download("webtronix.png",url);
- canvas.parentNode.removeChild(canvas);
- },
- addpart:function(url,cat,partname) {
- var listfile=function(partsvg){
- var part=new Element("div",{"id":"webtronics_"+partname,"class":"webtronics_menu_part",'style':"display:none",'title':partname})
- .update(partsvg);
- $("webtronics_"+cat).insert(part);
- Event.observe(part,'mousedown',function(e){
- var group=$$( "#"+ part.id+" g" )[0];
- webtronics.circuit.getgroup(group);
- webtronics.setMode('select','Selection');
- });
- Event.observe(part,'mouseup',function(e){
- webtronics.circuit.deleteSelection();
- });
-
-
- }
-
- if(url.indexOf("http://")==-1){
- openfile(url+'/'+cat+'/'+partname+'.svg',listfile);
-
- }
- else{
- new request(url,cat+"/"+partname+'.svg',listfile);
-
- }
-
- },
-
-
-//this takes an objectand returns a menu element
-makemenu:function(url, partlist,menu){
-
-
- for (var cat in partlist.parts){
- if(!$("webtronics_"+cat)){
- var category=new Element("div",{"id":"webtronics_"+cat})
- .insert(new Element("p").update(cat)
- .observe('click',function(e){
-
- var menuitems=$$('#'+menu.id+'>div>div');
-
- for(var i=0;i<menuitems.length;i++){
- if(menuitems[i].parentNode==Event.element(e).parentNode){
- if(menuitems[i].style.display=='none'){
- menuitems[i].style.display='block';
- }
- else{
- menuitems[i].style.display='none';
- }
- }
- else{
- menuitems[i].style.display='none';
- }
- }
- }));
- menu.insertBefore(category,menu.firstChild);
-
- for(var partname in partlist.parts[cat]){
- if(!$("webtronics_"+partname)){
- webtronics.addpart(url , cat,partname);
-
- }
- //if(partlist.parts[cat][partname].indexOf()<0){}
- }
-
- }
-
- }
- },
- populatemenu:function(){
- /*asynchronous part loading */
- $("webtronics_parts_list").innerHTML="";
- webtronics.serverurls.each(function(url){
- if(url=="webtronix_server"){
- openfile(url+"/parts.json",function(text){
- webtronics.partslists.push(text.evalJSON(true));
- webtronics.partslists[webtronics.partslists.length-1].url=url;
- webtronics.makemenu(url,webtronics.partslists[webtronics.partslists.length-1] , $("webtronics_parts_list"));
- });
-
- }
- else{
- new request(url,"parts.json",function(text){
- webtronics.partslists.push(text.evalJSON(true));
- webtronics.partslists[webtronics.partslists.length-1].url=url;
- webtronics.makemenu(url,webtronics.partslists[webtronics.partslists.length-1] , $("webtronics_parts_list"));
- });
-
- }
- }.bind(this));
-
-
- },
-
- opensources:function(){
- var sources=$$(".webtronics_add_source_input");
- for( var i=0;i<sources.length;i++){
- if(webtronics.serverurls[i])sources[i].value=webtronics.serverurls[i];
- else sources[i].value="";
- }
- $("webtronics_add source").style.display="block";
- this.center($("webtronics_add source"));
- this.disablepage();
- },
-
- /*all events are loaded here*/
- init:function(){
- Event.observe(window, 'load', function(){
- if (!window.console) {
- window.console = {};
- window.console.log = function(){};
- }
-
- webtronics.setsize();
- // $('webtronics_scope_display_iframe').src="";
- var menu;
- $("webtronics_showhelp").checked=false;
- $("webtronics_invert").checked=false;
- $("webtronics_graph").checked=false;
- $("webtronics_connections").checked=false;
-
- menu=this.createfilemenu($('webtronics_file').offsetLeft,
- $('webtronics_file').offsetTop+$('webtronics_file').offsetHeight,
- 'webtronics_file_menu',
- $('webtronics_main_window'),
- [{label:'sources',cb:webtronics.opensources},
- {label:'import',cb:webtronics.file_open},
- {label:'save',cb:webtronics.saveuri},
- {label:'kicad',cb:wtx2kicad},
- {label:'save-png',cb:webtronics.savepng},
- {label:'new',cb:webtronics.file_new}]);
- menu.observe('mouseout',function(e){
- if((e.relatedTarget!=null)&&!((e.relatedTarget == menu) || e.relatedTarget.descendantOf(menu))){
- // if(!(e.relatedTarget == menu) ){
- menu.style.display='none';
- }
- });
-
- $("webtronics_main_window").insertBefore(menu,$("webtronics_disable"));
-
-
- /*replace context menu*/
- var myLinks = [
- {label:'copy',cb:function(){
- webtronics.copy=webtronics.circuit.copy();
- $('webtronics_context_menu').style.display='none';
- }},
- {label:'paste',cb:function(){
- webtronics.circuit.paste(webtronics.copy);
- $('webtronics_context_menu').style.display='none';}},
-
- {label:'delete',cb:function(){
- webtronics.circuit.deleteSelection();
- $('webtronics_context_menu').style.display='none';}},
-
- {label:'Properties',cb:function(){
- webtronics.openProperties()
- webtronics.center($('webtronics_properties_div'));
- document.forms['webtronics_properties_form'].focus();
- $('webtronics_context_menu').style.display='none';
-
-
- }}];
- var contextmenu=this.createfilemenu(0,
- 0,
- 'webtronics_context_menu',
- $('webtronics_diagram_area'),
- myLinks);
- $("webtronics_diagram_area").insert(contextmenu);
- /*add a new frame */
- var frame=new Element('iframe',{id:'webtronics_display_frame',src:'canvas/canvas.html'});
- $('webtronics_diagram_area').insert(frame);
-
- Event.observe(frame,'load',function(){
- var filename='Schematic.svg';
- this.attachframe(filename,frame);
- }.bind(this));
-
- Event.observe(window, 'resize', function() {
- webtronics.setsize();
- webtronics.circuit.addtools();
- });
-
- $('webtronics_toolbar').onselectstart = function() {return false;}
-
- $('webtronics_diagram_area').onselectstart = function() {return false;}
- $('webtronics_side_bar').onselectstart = function() {return false;}
-
-
-//populate default menu
-
-webtronics.populatemenu();
-
-
-
-
-
-
-/*chipmaker*/
-$("webtronics_hor_pins").insert(Element("option",{"value":0}).update(0));
-for(var i=1;i<50;i++){
- if(i>3){
- $("webtronics_hor_pins").insert(Element("option",{"value":i}).update(i*2));
- }
- $("webtronics_vert_pins").insert(Element("option",{"value":i}).update(i*2));
-
-}
-
-/*menu events*/
-
-Event.observe($('webtronics_file'), 'click', function() {
- if($('webtronics_file_menu').style.display=='block'){
- $('webtronics_file_menu').style.display='none';
- }
- else {
- $('webtronics_file_menu').style.display='block';
- }
-});
-Event.observe($('webtronics_chips_open'), 'click', function() {
- webtronics.circuit.clearinfo();
- webtronics.setMode('select','Selection');
- chipmaker.openmaker();
- $('webtronics_chips_box').style.display = "block";
- webtronics.center($('webtronics_chips_box'));
- webtronics.disablepage();
-});
-if($("webtronics_select"))Event.observe($('webtronics_select'), 'click', function() {
- webtronics.circuit.clearinfo();
- webtronics.setMode('select', 'Selection');
-});
- if($("webtronics_wire"))Event.observe($('webtronics_wire'), 'click', function() {
- webtronics.circuit.clearinfo();
- webtronics.setMode('line','Wire');
- });
- Event.observe($('webtronics_text'), 'click', function() {
- webtronics.circuit.clearinfo();
- if($('webtronics_text').className=='pressed_button'){
- $('webtronics_text').className = 'normal_button';
- webtronics.setMode('select', 'Selection');
- }
- else {
- $('webtronics_text').className = 'pressed_button';
- webtronics.setMode('text', 'Text');
- }
-
- });
- if($('webtronics_undo')){
- Event.observe($('webtronics_undo'),'click',function(){
- webtronics.circuit.undo();
-
- });
- }
- if($('webtronics_redo')){
- Event.observe($('webtronics_redo'),'click',function(){
- webtronics.circuit.redo();
- });
- }
-
- Event.observe($('webtronics_delete'), 'click', function() {
- webtronics.circuit.clearinfo();
- webtronics.circuit.addhistory();
- webtronics.circuit.deleteSelection();
- });
-/*
- if($('webtronics_save')){
- Event.observe($('webtronics_save'), 'click', function() {
- webtronics.circuit.clearinfo();
- webtronics.showMarkup();
- });
- }
- */
-
- flag1=0;
-
-
-
- jQuery("#analysis_selectbox").change(function(){
-
- analysis_type = jQuery(this).val();
-
- });
-
-
-
-
-
- if($('webtronics_netlist')){
- Event.observe($('webtronics_netlist'), 'click', function() {
- if(flag1!=0){
-
- netlistcreator.createnetlist(function(netlist){
- var content=$$("#webtronics_netlist_text_div > *")
- for(var i=0;i<content.length;i++){
- $("webtronics_netlist_text_div").removeChild(content[i]);
- }
- $("webtronics_netlist_text_div").insert(webtronics.formatnetlist(netlist,null));
- $("webtronics_netlist_text").style.display='block';
- globalVariable=1;
- webtronics.center($('webtronics_netlist_text_div'));
- webtronics.disablepage();});
-
-
-
-
- jQuery('#webtronics_netlist_buttons').show();
-
-
-
-
-
- change_val = "0";
- Flag = "";
- //console.log("out")
-
-
- if (change_val == "0")
- {
- Flag = jQuery("#webtronics_netlist_text_area").val();
-
-
-/*-------------------------------------------------------------------------------------------------------------------------------------
- Here are the conditions concatenated to give final netlist values for dc all cases
- ---------------------------------------------------------------------------------------------------------------------------------------------*/
- if (analysis_type == "1")
- {
-
- console.log(jQuery("#analysis_selectbox").val());
-
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".dc" + " " + source + " " + start + "e" + "-" + start_dc_unit + " " + stop + "e" + "-" + stop_dc_unit + " " + increment + "e" + "-" + increment_dc_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
-
- change_val = "1";
- console.log(jQuery("#analysis_selectbox").val());
-}
-
-
-/*------------------------------------------------------------------------------------------------------------------------------------------------
-Here are the all AC Cases for generating final netlist values
-------------------------------------------------------------------------------------------------------------------------------------------------*/
-else if (analysis_type == "2")
-{
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".ac" + " " + scale_val + " " + noofpoint + " " + startfreq + start_ac_unit + " " + stopfreq + stop_ac_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
-
- change_val = "1";
-}
-/*------------------------------------------------------------------------------------------------------------------------------------------------
-Here are the all Transiet Cases for generating final netlist values
-------------------------------------------------------------------------------------------------------------------------------------------------*/
- //else if (analysis_type == "3" && time == "1")
- else if (analysis_type== "3")
- {
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n' + ".tran" + " " + step_trans + "e" + "-" + step_trans_unit + " " + stop_trans + "e"+ "-" + stop_trans_unit + " " + start_trans + "e" + "-" + start_trans_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n" +".end \n" );
-
- change_val = "1";
- }
-
-
-}
-
-else if( change_val == "1")
-
-{
-
- jQuery("#webtronics_netlist_text_area").val("");
- //console.log("if when 1")
-
- if (analysis_type == "1")
-
- {
-
-
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".dc" + " " + source + " " + start + "e" + "-" + start_dc_unit + " " + stop + "e" + "-" + stop_dc_unit + " " + increment + "e" + "-" + increment_dc_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
- change_val = "1";
- }
-
-
-
- else if (analysis_type == "2")
- {
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".ac" + " " + scale_val + " " + noofpoint + " " + startfreq + start_ac_unit + " " + stopfreq + stop_ac_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" );
-
- change_val = "1";
- }
-
-
- else if (analysis_type == "3")
- {
- jQuery("#webtronics_netlist_text_area").val(Flag + '\n' + ".tran" + " " + step_trans + "e" + "-" + step_trans_unit + " " + stop_trans + "e"+ "-" + stop_trans_unit + " " + start_trans + "e" + "-" + start_trans_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n" +".end \n" );
-
- change_val = "1";
- }
-
-
- }
-
-
-
-
-
-
-
-}
-else {
- alert("Analysis information is not available !");
-
-
-}
-
-
-
-
-});
-}
-
-
-
-
-
-jQuery("#webtronics_analysis").click(function(){
- flag1=1;
- jQuery('#webtronics_netlist_analysis').show();
-
- jQuery('#webtronics_disable').show();
-
-
-
-});
-
-jQuery(".button_cancel").click(function(){
- flag1=0;
- jQuery("#webtronics_netlist_analysis").hide();
- jQuery("#webtronics_disable").hide();
-
-});
-
-
-
-
-
-if($('webtronics_run')){
- Event.observe($('webtronics_run'), 'click', function() {
- // webtronics.postspice(webtronics.circuit.createnetlist());
- netlistcreator.createnetlist(webtronics.gnucapjs);
- });
-
-}
-
-if($('webtronics_invert')){
-
- Event.observe($('webtronics_invert'),'click',function(){
- webtronics.circuit.invert($('webtronics_invert').checked);
-
- });
-}
-if($('webtronics_graph')){
- Event.observe($('webtronics_graph'),'click',function(){
- if($('webtronics_graph').checked){
- webtronics.circuit.graph=true;
- webtronics.circuit.showbackground();
- }
- else{
- webtronics.circuit.graph=false;
- webtronics.circuit.showbackground();
- }
- });
-}
-if($('webtronics_connections')){
- $('webtronics_connections').checked=false;
- Event.observe($('webtronics_connections'),'click',function(){
- webtronics.circuit.showconnections($('webtronics_connections').checked);
-
- });
-}
-if($("webtronics_showhelp")){
- Event.observe($("webtronics_showhelp"),"click",function(){
- if($("webtronics_showhelp").checked){
- $$(".webtronics_help").forEach(function(e){
- e.style.display="block";
- });
- }
- else{
- $$(".webtronics_help").forEach(function(e){
- e.style.display="none";
- });
- }
-});
-}
-/*properties events*/
-
-
-if($('webtronics_properties_ok'))Event.observe($('webtronics_properties_ok'), 'click', function() {
- $("webtronics_print_dir_field").style.display="none";
- $('webtronics_properties_div').style.display='none';
- webtronics.enablepage();
- var model=webtronics.circuit.selected[0];
- netlistcreator.writewtx(model,"id",$('webtronics_part_id').value);
- netlistcreator.writewtx(model,"value",$('webtronics_part_value').value);
- netlistcreator.writewtx(model,"model",$('webtronics_part_dir_value').value);
- netlistcreator.writewtx(model,"measure",$('webtronics_print_dir_value').value);
-
- var modelname=netlistcreator.readwtx(model,"name");
-
- if(modelname=="ac"){
- netlistcreator.writewtx(model,"phase",$('webtronics_phase_value').value);
- netlistcreator.writewtx(model,"amplitude",$('webtronics_amplitude_value').value);
-
- }
- else if(modelname=="sinvoltagesource"){
- netlistcreator.writewtx(model,"offsetvoltage",$('webtronics_offsetvoltage_value').value);
- netlistcreator.writewtx(model,"voltageamplitude",$('webtronics_voltageamplitude_value').value);
- netlistcreator.writewtx(model,"frequency",$('webtronics_frequency_value').value);
- netlistcreator.writewtx(model,"delaytime",$('webtronics_delaytime_value').value);
- netlistcreator.writewtx(model,"dampingfactor",$('webtronics_dampingfactor_value').value);
-
- }
- else if(modelname=="pulse"){
- netlistcreator.writewtx(model,"pulval1",$('webtronics_pulval1_value').value);
- netlistcreator.writewtx(model,"pulval2",$('webtronics_pulval2_value').value);
- netlistcreator.writewtx(model,"pulval3",$('webtronics_pulval3_value').value);
- netlistcreator.writewtx(model,"pulval4",$('webtronics_pulval4_value').value);
- netlistcreator.writewtx(model,"pulval5",$('webtronics_pulval5_value').value);
- netlistcreator.writewtx(model,"pulval6",$('webtronics_pulval6_value').value);
- netlistcreator.writewtx(model,"pulval7",$('webtronics_pulval7_value').value);
- }
- else if(modelname=="pwl"){
- netlistcreator.writewtx(model,"pwlval1",$('webtronics_pwlval1_value').value);
- netlistcreator.writewtx(model,"pwlval2",$('webtronics_pwlval2_value').value);
- netlistcreator.writewtx(model,"pwlval3",$('webtronics_pwlval3_value').value);
- netlistcreator.writewtx(model,"pwlval4",$('webtronics_pwlval4_value').value);
- netlistcreator.writewtx(model,"pwlval5",$('webtronics_pwlval5_value').value);
- netlistcreator.writewtx(model,"pwlval6",$('webtronics_pwlval6_value').value);
- netlistcreator.writewtx(model,"pwlval7",$('webtronics_pwlval7_value').value);
- netlistcreator.writewtx(model,"pwlval8",$('webtronics_pwlval8_value').value);
- }
- else if(modelname=="exponential"){
- netlistcreator.writewtx(model,"eval1",$('webtronics_eval1_value').value);
- netlistcreator.writewtx(model,"eval2",$('webtronics_eval2_value').value);
- netlistcreator.writewtx(model,"eval3",$('webtronics_eval3_value').value);
- netlistcreator.writewtx(model,"eval4",$('webtronics_eval4_value').value);
- netlistcreator.writewtx(model,"eval5",$('webtronics_eval5_value').value);
- netlistcreator.writewtx(model,"eval6",$('webtronics_eval6_value').value);
- }
-
- else if(modelname=="and"|| c=='not'|| c=='nand'|| c=='or'||c=='nor'||c=='xor'||c=='xnor'){
- netlistcreator.writewtx(model,"risedelay",$('webtronics_risedelay_value').value);
- netlistcreator.writewtx(model,"falldelay",$('webtronics_falldelay_value').value);
- netlistcreator.writewtx(model,"inputload",$('webtronics_inputload_value').value);
- }
-
- webtronics.circuit.createvalue(webtronics.circuit.selected[0]);
-});
-
- if($('webtronics_properties_cancel'))Event.observe($('webtronics_properties_cancel'), 'click', function() {
- $("webtronics_print_dir_field").style.display="none";
- $('webtronics_properties_div').style.display='none';
- webtronics.enablepage();
- });
-
- if($('webtronics_part_model'))Event.observe($('webtronics_part_model'),'change',function(){
- var part=netlistcreator.readwtx(webtronics.circuit.selected[0],"name");
- var cat=netlistcreator.readwtx(webtronics.circuit.selected[0],"category");
- if($('webtronics_part_model').value){
- $("webtronics_part_dir_model").options.length=0;
- $("webtronics_part_dir_model").appendChild(new Element("option",{"value":""}).update("none"));
- for( var i=0;i<webtronics.partslists.length;i++){
- for(var j=0;j<webtronics.partslists[i].parts[cat][part].values[$('webtronics_part_model').value].length;j++){
- $("webtronics_part_dir_model").insert(new Element("option",{"value":webtronics.partslists[i].parts[cat][part].values[$('webtronics_part_model').value][j]}).update(webtronics.partslists[i].parts[cat][part].values[$('webtronics_part_model').value][j]));
- }
- }
- }
- $('webtronics_part_value').value=$("webtronics_part_model").options[$("webtronics_part_model").selectedIndex].value;
-
- });
-
- if($('webtronics_part_dir_model'))Event.observe($('webtronics_part_dir_model'),'change',function(){
- $('webtronics_part_dir_value').value=$("webtronics_part_dir_model").options[$("webtronics_part_dir_model").selectedIndex].value;
-
- });
- //**OPEN LOCAL SPICE MODELS EXPERIMENT
- // if($("webtronics_part_file"))Event.observe($("webtronics_part_file"),'change',function(){
- // console.log($("webtronics_part_file").files[0]);
- // if(window.FileReader){
- //
- // var textReader = new FileReader();
- // textReader.onloadend=function(){
- // if(!textReader.result){
- // console.log("error opening file");
- // return;
- // };
- //
- // }.bind(this);
- // textReader.readAsText();
- // }
- // }.bind(this));
-
- /*save as png modal*/
- if($("webtronics_image_ok")){
- Event.observe($('webtronics_image_ok'), 'click', function() {
- webtronics.enablepage();
- $('webtronics_image').style.display='none';
- webtronics.setMode('select','Selection');
- });
-
-
- }
-
- /*chip box events*/
- Event.observe($('webtronics_vert_pins'), 'change', function() {
- $("webtronics_chip_display").parentNode.removeChild($("webtronics_chip_display"));
- var div=new Element("div",{id:"webtronics_chip_display"})
- .insert(chipmaker.drawchip($('webtronics_hor_pins').value,$('webtronics_vert_pins').value));
- $("webtronics_chips_box").insertBefore(div,$("webtronics_chips_box").firstChild);
- });
- Event.observe($('webtronics_hor_pins'), 'change', function() {
- $("webtronics_chip_display").parentNode.removeChild($("webtronics_chip_display"));
- var div=new Element("div",{id:"webtronics_chip_display"})
- .update(chipmaker.drawchip($('webtronics_hor_pins').value,$('webtronics_vert_pins').value));
- $("webtronics_chips_box").insertBefore(div,$("webtronics_chips_box").firstChild);
- });
-
- Event.observe($('webtronics_chip_spice_select'), 'change', function() {
- $("webtronics_chip_display").parentNode.removeChild($("webtronics_chip_display"));
- var div=new Element("div",{id:"webtronics_chip_display"})
- $("webtronics_chips_box").insertBefore(div,$("webtronics_chips_box").firstChild);
- $("webtronics_chip_spice").value=$('webtronics_chip_spice_select').value;
- if($('webtronics_chip_spice_select').value!="none"){
- openfile("symbols/predefined/"+$('webtronics_chip_spice_select').value+".svg",function(svg){
- div.update(svg);
- var model=$("webtronics_chip_display").getElementsByTagName("g")[0];
- netlistcreator.writewtx(model,"value",$('webtronics_chip_spice_select').value);
- netlistcreator.writewtx(model,"model",webtronics.models[$('webtronics_chip_spice_select').value]);
- });
- }
- });
-
-
- Event.observe($('webtronics_chip_ok'), 'click', function() {
- webtronics.enablepage()
- webtronics.returnchip();
- //chipmaker.clear();
- });
- Event.observe($('webtronics_chip_cancel'), 'click', function() {
- webtronics.enablepage();
- $('webtronics_chips_box').style.display='none';
- webtronics.setMode('select','Selection');
- });
- /*text add events*/
- if($("webtronics_text_ok")){
- Event.observe($('webtronics_text_ok'), 'click', function() {
- webtronics.circuit.addtext($('webtronics_comment').value);
- $('webtronics_add_text').style.display='none';
- webtronics.setMode('select','Selection');
- });
- }
- if($("webtronics_text_cancel")){
- Event.observe($('webtronics_text_cancel'), 'click', function() {
- webtronics.setMode('select','Selection');
- $('webtronics_add_text').style.display='none';
- });
- }
- /*netlist text events*/
- if($("webtronics_netlist_text_ok")){
- Event.observe($('webtronics_netlist_text_ok'), 'click', function() {
- webtronics.setMode('select','Selection');
- $('webtronics_netlist_text').style.display='none';
- webtronics.enablepage();
- });
- }
-
-
-
-
-
-
-
- if($("webtronics_netlist_text_run")){
- Event.observe($('webtronics_netlist_text_run'), 'click', function() {
- webtronics.gnucapjs($("webtronics_netlist_text_area").value);
- //$('webtronics_netlist_text').style.visibility='none';
- //webtronics.enablepage();
- });
- }
- /*scope events*/
- if($("webtronics_scope_display")){
- this.scopestatus=$("webtronics_scope_status");
- this.scopedata=$("webtronics_scope_data");
-
- $("webtronics_scope_output_graph").checked=true;
- Event.observe($("webtronics_scope_output_graph"),'click',function(){$("webtronics_scope_display_frame").contentWindow.displaygraph()});
- Event.observe($("webtronics_scope_output_log"),'click', function(){$("webtronics_scope_display_frame").contentWindow.displaylog()});
-
- Event.observe($('webtronics_scope_display_ok'), 'click', function() {
- webtronics.setMode('select','Selection');
- $('webtronics_scope_display').style.display='none';
- $('webtronics_scope_display_div').innerHTML="";
- // webtronics.enablepage();
- });
- Event.observe($('webtronics_scope_display_stop'), 'click', function() {
- webtronics.setMode('select','Selection');
- $("webtronics_scope_display_frame").contentWindow.stopsimulation()
-// $('webtronics_scope_display').style.display='none';
-// $('webtronics_scope_display_div').innerHTML="";
- // webtronics.enablepage();
- });
-
-
-
- Event.observe($("webtronics_scope_display"),'mousedown',function(e){
- var startx=e.layerX;
- var starty=e.layerY;
- Event.observe($("webtronics_scope_display"),'mousemove',function(e){
- $("webtronics_scope_display").style.top =e.clientY-starty + 'px';
- $("webtronics_scope_display").style.left =e.clientX-startx + 'px';
- });
- e.preventDefault();
- });
- Event.observe($("webtronics_scope_display"),'mouseup',function(){
- Event.stopObserving($("webtronics_scope_display"),'mousemove');
- });
-
- }
-
-
-
- /*text open events*/
- Event.observe($('webtronics_open_text_ok'), 'click', function() {
- $('webtronics_open_text').style.display='none';
- });
- Event.observe($('webtronics_open_text_cancel'), 'click', function() {
- webtronics.setMode('select','Selection');
-
- $('webtronics_open_text').style.display='none';
- });
- //sources events
- Event.observe($('webtronics_add source_ok'), 'click', function() {
- var sources=$$(".webtronics_add_source_input");
- var addresses=[]
- for( var i=0;i<sources.length;i++){
- if(sources[i].value.match(/.*/)!=-1)addresses.push(sources[i].value);
- }
- webtronics.serverurls=addresses;
- webtronics.populatemenu();
- $('webtronics_add source').style.display='none';
- webtronics.enablepage();
- });
-
- Event.observe($("webtronics_add_source_cancel"), 'click', function() {
- webtronics.setMode('select','Selection');
-
- $('webtronics_add source').style.display='none';
- webtronics.enablepage();
- });
-
-
-
- }.bind(this));
-
-}
-}
-webtronics.init();
diff --git a/views/script/netlist.js b/views/script/netlist.js index 5ab7947..d8a3655 100644 --- a/views/script/netlist.js +++ b/views/script/netlist.js @@ -1095,7 +1095,9 @@ else if(sections.netlist[i].name=="memristor"){ command+=" ref_"+pid+"\n"+".model ref_"+pid+" memristor(rmin="+ct+" rmax="+pw+" rinit="+ctg+" alpha="+pt+" beta="+ol+" vt="+oh+")\n"; } else{ + command+=" "+sections.netlist[i].model; + } if(command!="")spice+=command+'\n'; } @@ -1119,7 +1121,7 @@ var modelloader={ found=true; if(webtronics.partslists[i].url.indexOf("http://")==-1){//see if path is local - openfile( webtronics.partslists[i].url+"/spice/"+ name,this.responder); + openfile( webtronics.partslists[i].url+"/spice/"+ name,this.responder); } else{ server.requestfile(list.url,this.responder); @@ -1129,36 +1131,48 @@ var modelloader={ } } + if(!found)console.log("model not found"); }, finish:function(){ + spice+=modelloader.modeltext; + if(sections.simulation.length){ for(var i=0;i<sections.simulation.length;i++){ if(sections.simulation[i]!="")spice+=sections.simulation[i]+"\n"; } } + if(sections.lastdir.length){ sections.lastdir=sections.lastdir.uniq(); for(var i=0;i<sections.lastdir.length;i++){ if(sections.lastdir[i]!="")spice+=sections.lastdir[i]+"\n"; } } + + responsefunc(spice); + + console.log((final_str)); + console.log((spice)); }, responder:function(text){ console.log("reponded"); - modelloader.modeltext+=text; - if(!modelloader.modelcount){ - modelloader.finish(); - spice=spice.concat(".end \n"); + modelloader.modeltext=text; + if(!modelloader.modelcount){ + //spice+=modelloader.modeltext; + + + modelloader.finish(); + jQuery("#webtronics_netlist_text_area").val(spice+final_str); + //spice=spice.concat(".end \n"); } } } - if(sections.firstdir.length){ sections.firstdir=sections.firstdir.uniq(); @@ -1282,3 +1296,4 @@ writewtx:function(elem,value,text){ } + diff --git a/views/script/netlist.js~ b/views/script/netlist.js~ deleted file mode 100644 index 8265718..0000000 --- a/views/script/netlist.js~ +++ /dev/null @@ -1,839 +0,0 @@ -var netlistcreator={ - matrixxform:function(point,matrix){ - var pin=webtronics.circuit.svgRoot.createSVGPoint(); - pin.x=point.x; - pin.y=point.y; - pin=pin.matrixTransform(matrix); - return {x:Math.round(pin.x),y:Math.round(pin.y)}; - }, - - /*tests if 2 point are within 3 pixels of each other*/ - ispoint:function(point1,point2){ - return (Math.abs(point2.x-point1.x)<3)&&(Math.abs(point2.y-point1.y)<3); - }, - - sortnetlist:function(list){ - var G=[]; - var S=[]; - var A=[]; - var B=[]; - var C=[]; - var D=[]; - var I=[]; - var J=[]; - var K=[]; - var L=[]; - var M=[]; - var N=[]; - var P=[]; - var Q=[]; - var R=[]; - var U=[]; - var V=[]; - var wire=[]; - var other=[] - for(var i=0;i<list.length;i++){ - if(list[i].type=='gnd'){ - G.push(list[i]); - } - else if(list[i].type=='v'){ - V.push(list[i]); - } - else if(list[i].type=='wire'){ - wire.push(list[i]); - } - else if(list[i].type=='b'){ - B.push(list[i]); - } - else if(list[i].type=='c'){ - C.push(list[i]); - } - else if(list[i].type=='d'){ - D.push(list[i]); - } - else if(list[i].type=='i'){ - J.push(list[i]); - } - else if(list[i].type=='j'){ - J.push(list[i]); - } - else if(list[i].type=='k'){ - K.push(list[i]); - } - else if(list[i].type=='l'){ - L.push(list[i]); - } - else if(list[i].type=='m'){ - M.push(list[i]); - } - else if(list[i].type=='n'){ - N.push(list[i]); - } - else if(list[i].type=='plot'){ - P.push(list[i]); - } - else if(list[i].type=='q'){ - Q.push(list[i]); - } - else if(list[i].type=='r'){ - R.push(list[i]); - } - else if(list[i].type=='u'){ - U.push(list[i]); - } - /* this is the best way I could think to tell if a part i digital */ - else if(list[i].category=="digital"){ - A.push(list[i]); - } - else { - list[i].error='unknown device'; - other.push(list[i]); - } - } - - var sortfunction=function(a,b){ - var apart=a.id.replace(a.type,""); - var bpart=b.id.replace(b.type,""); - if(!apart)apart=0; - if(!bpart)bpart=0; - return (apart>bpart); - }; - V.sort(sortfunction); - wire.sort(sortfunction); - B.sort(sortfunction); - C.sort(sortfunction); - D.sort(sortfunction); - I.sort(sortfunction); - J.sort(sortfunction); - K.sort(sortfunction); - L.sort(sortfunction); - M.sort(sortfunction); - N.sort(sortfunction); - P.sort(sortfunction); - Q.sort(sortfunction); - R.sort(sortfunction); - U.sort(sortfunction); - A.sort(sortfunction); - - var newlist=[]; - G.each(function(item){newlist.push(item)}); - G.reverse(); - V.each(function(item){newlist.push(item)}); - wire.each(function(item){newlist.push(item)}); - B.each(function(item){newlist.push(item)}); - C.each(function(item){newlist.push(item)}); - D.each(function(item){newlist.push(item)}); - I.each(function(item){newlist.push(item)}); - J.each(function(item){newlist.push(item)}); - K.each(function(item){newlist.push(item)}); - L.each(function(item){newlist.push(item)}); - M.each(function(item){newlist.push(item)}); - N.each(function(item){newlist.push(item)}); - Q.each(function(item){newlist.push(item)}); - R.each(function(item){newlist.push(item)}); - U.each(function(item){newlist.push(item)}); - A.each(function(item){newlist.push(item)}); - other.each(function(item){newlist.push(item)}); - - /*plots go last*/ - P.each(function(item){newlist.push(item)}); - - - return newlist; - }, - - /* draws wires to namewire ports with the same id*/ - connectnamewires:function(list){ - - for(var i=0;i<list.length;i++){ - if((list[i].type=="wire") || (list[i].type=="gnd")){ - for(var j=i;j<list.length;j++){ - if( (list[i]!=list[j]) && ((list[i].id==list[j].id) || (list[i].type=="gnd" && list[j].type=="gnd")) ){ - var line= webtronics.circuit.createline('yellow',1,list[i]['analogpins'][0]['x'],list[i]['analogpins'][0]['y'],list[j]['analogpins'][0]['x'],list[j]['analogpins'][0]['y']); - line.setAttributeNS(null,'class','webtronics_namewire_connector'); - webtronics.circuit.info.appendChild(line); - //console.log(line); - break; - } -} -} -} -}, - -/*check for vectors and convert them*/ -tovector:function(pin,nodenumber){ - var v =""; - if(pin.parentNode.tagName=="wtx:vector"){ - var vector=Element.descendants(pin.parentNode); - if(pin==vector[0]){v+="["} - v+="a"+nodenumber; - if(pin==vector[vector.length-1]){v+="]";} - } - else{ - v+="a"+nodenumber; - } - - return v; -}, - -/* - * <wtx:pins> - * <wtx:analog> - * <wtx:node index="1" x="0" y="10"></wtx:node> - * <wtx:node index="2" x="40" y="10"></wtx:node> - * </wtx:analog> - * </wtx:pins> - * <wtx:id>r</wtx:id> - * <wtx:type>r</wtx:type> - * <wtx:name>testresistor</wtx:name> - * <wtx:category>resistors</wtx:category> - * <wtx:value></wtx:value> - * <wtx:label></wtx:label> - * <wtx:spice></wtx:spice> - * <wtx:flip></wtx:flip> - * <wtx:model></wtx:model> - */ - - - getwtxdata:function(parts){ - list=[]; - for(var i=0;i<parts.length;i++){ - var part={error:"", elem:{}, analogpins:[],digitalpins:[],amplitude:"",phase:"",offsetvoltage:"",voltageamplitude:"",frequency:"",delaytime:"",dampingfactor:"",type:"", name:"", category:"", value:"", spice:"", model:"",measure:"", risedelay:"", falldelay:"", pulval1:"", pulval2:"", pulval3:"", pulval4:"", pulval5:"", pulval6:"", pulval7:"", eval1:"", eval2:"", eval3:"", eval4:"", eval5:"", eval6:"", pwlval1:"", pwlval2:"", pwlval3:"", pwlval4:"", pwlval5:"", pwlval6:"", pwlval7:"", pwlval8:"" - } - /* - * try{ - * part.nodes=this.getwtxpins(part[i]); - } - catch{part.error="wtx:pins not found"} - */ - part.elem=parts[i]; - - try{ - var category=webtronics.circuit.getwtxtagname(parts[i],"analog")[0]; - var nodes = webtronics.circuit.getwtxtagname(category,"node"); - for(var j=0;j<nodes.length;j++){ - var point = this.matrixxform( {x:webtronics.circuit.getwtxattribute(nodes[j],"x"),y:webtronics.circuit.getwtxattribute(nodes[j],"y")},webtronics.circuit.parseMatrix(part.elem)); - part.analogpins.push({index:webtronics.circuit.getwtxattribute(nodes[j],"index"),x:point.x,y:point.y,node:undefined}) ; - } - //sort nodes int correct order - part.analogpins.sort(function(a,b){if (a.name > b.name)return 1;if (a.name < b.name)return -1;return 0;}); - } - catch(e){console.log("no analog pins found");} - - try{ - var category=webtronics.circuit.getwtxtagname(parts[i],"digital")[0]; - var nodes = webtronics.circuit.getwtxtagname(category,"node"); - for(var j=0;j<nodes.length;j++){ - var point = this.matrixxform( {x:webtronics.circuit.getwtxattribute(nodes[j],"x"),y:webtronics.circuit.getwtxattribute(nodes[j],"y")},webtronics.circuit.parseMatrix(part.elem)); - part.digitalpins.push({index:webtronics.circuit.getwtxattribute(nodes[j],"index"),x:point.x,y:point.y,node:undefined}) ; - } - part.digitalpins.sort(function(a,b){if (a.name > b.name)return 1;if (a.name < b.name)return -1;return 0;}); - } - catch(e){console.log("no digital pins found");} - try{ - part.id=this.readwtx(parts[i],'id'); - if(part.type=="gnd"){part.id=part.type;this.writewtx(parts[i],'id',part.id);console.log(this.readwtx(parts[i],'id')+" sfd ");} - } - catch(e){part.error="wtx:id not found";} - try{ - part.type=this.readwtx(parts[i],'type'); - } - catch(e){ - part.error="wtx:type not found"; - } - try{ - part.name=this.readwtx(parts[i],'name'); - } - catch(e){part.error="wtx:name not found";} - try{ - part.category=this.readwtx(parts[i],'category'); - } - catch(e){part.error="wtx:category not found";} - try{ - part.value=this.readwtx(parts[i],'value'); - - } - catch(e){part.error="wtx:value not found";} - try{ - part.spice=this.readwtx(parts[i],'spice'); - } - catch(e){part.error="wtx:spice not found";} - try{ - part.model=this.readwtx(parts[i],'model'); - } - catch(e){part.error="wtx:model not found";} - //for ac voltage source - try{ - part.amplitude=this.readwtx(parts[i],'amplitude'); - - - } - - catch(e){part.error="wtx:amplitude not found";} - try{ - part.phase=this.readwtx(parts[i],'phase'); - } - catch(e){part.error="wtx:phase not found";} - - //for sinusoidal voltage source - - try{ - part.offsetvoltage=this.readwtx(parts[i],'offsetvoltage'); - } - catch(e){part.error="wtx:offsetvoltage not found";} - - try{ - part.voltageamplitude=this.readwtx(parts[i],'voltageamplitude'); - } - catch(e){part.error="wtx:voltageamplitude not found";} - try{ - part.frequency=this.readwtx(parts[i],'frequency'); - } - catch(e){part.error="wtx:frequency not found";} - try{ - part.delaytime=this.readwtx(parts[i],'delaytime'); - } - catch(e){part.error="wtx:delaytime not found";} - try{ - part.dampingfactor=this.readwtx(parts[i],'dampingfactor'); - } - catch(e){part.error="wtx:dampingfactor not found";} - - // FOR pulse volatge source - try{ - part.pulval1=this.readwtx(parts[i],'pulval1'); - } - catch(e){part.error="wtx:Initial Value not found";} - - try{ - part.pulval2=this.readwtx(parts[i],'pulval2'); - } - catch(e){part.error="wtx:Pulse Value not found";} - try{ - part.pulval3=this.readwtx(parts[i],'pulval3'); - } - catch(e){part.error="wtx:Delay Time not found";} - try{ - part.pulval4=this.readwtx(parts[i],'pulval4'); - } - catch(e){part.error="wtx:Rise Time not found";} - - try{ - part.pulval5=this.readwtx(parts[i],'pulval5'); - } - catch(e){part.error="wtx:Fall Time not found";} - try{ - part.pulval6=this.readwtx(parts[i],'pulval6'); - } - catch(e){part.error="wtx:Pulse Period not found";} - try{ - part.pulval7=this.readwtx(parts[i],'pulval7'); - } - catch(e){part.error="wtx:Pulse Width not found";} - - //FOR pwl volatge source - try{ - part.pwlval1=this.readwtx(parts[i],'pwlval1'); - } - catch(e){part.error="wtx:Time T1 Value not found";} - - try{ - part.pwlval2=this.readwtx(parts[i],'pwlval2'); - } - catch(e){part.error="wtx:Voltage V1 Value not found";} - try{ - part.pwlval3=this.readwtx(parts[i],'pwlval3'); - } - catch(e){part.error="wtx:Time T2 Value not found";} - try{ - part.pwlval4=this.readwtx(parts[i],'pwlval4'); - } - catch(e){part.error="wtx:Voltage V2 value not found";} - - try{ - part.pwlval5=this.readwtx(parts[i],'pwlval5'); - } - catch(e){part.error="wtx:Time T3 value not found";} - try{ - part.pwlval6=this.readwtx(parts[i],'pwlval6'); - } - catch(e){part.error="wtx:Voltage V3 value not found";} - try{ - part.pwlval7=this.readwtx(parts[i],'pwlval7'); - } - catch(e){part.error="wtx:Time T4 Value not found";} - try{ - part.pwlval8=this.readwtx(parts[i],'pwlval8'); - } - catch(e){part.error="wtx:Voltage V4 Value not found";} - -//FOR exponential volatge source -try{ - part.eval1=this.readwtx(parts[i],'eval1'); -} -catch(e){part.error="wtx:Initial Value not found";} - -try{ - part.eval2=this.readwtx(parts[i],'eval2'); -} -catch(e){part.error="wtx:Pulse Value not found";} -try{ - part.eval3=this.readwtx(parts[i],'eval3'); -} -catch(e){part.error="wtx:Rise Time Delay value not found";} -try{ - part.eval4=this.readwtx(parts[i],'eval4'); -} -catch(e){part.error="wtx:Rise Time Constant value not found";} - -try{ - part.eval5=this.readwtx(parts[i],'eval5'); -} -catch(e){part.error="wtx:Fall Time Delay value not found";} -try{ - part.eval6=this.readwtx(parts[i],'eval6'); -} -catch(e){part.error="wtx:Fall Time Constan value not found";} - -//digital and - try{ - part.risedelay=this.readwtx(parts[i],'risedelay'); - } -catch(e){ - part.error="wtx:risedelay not found";} - -try{ - part.falldelay=this.readwtx(parts[i],'falldelay'); - } -catch(e){ - part.error="wtx:risedelay not found";} - -try{ - part.inputload=this.readwtx(parts[i],'inputload'); - } -catch(e){ - part.error="wtx:inputload not found";} - - - //special tag for parts that do simulation - try{ - part.measure=this.readwtx(parts[i],'measure'); - } - catch(e){} - - list.push(part); - } - return list; - -}, -/*detect analog and digital mix*/ -mixedsignals:function(analogwires,digitalwires){ - - for(var j=1;j<analogwires.length;j++){ - var crossed=this.getconnected(digitalwires,analogwires[j]); - if(crossed>-1){ - return true; - } - } - return false; -}, - -/* test if wires are connected anywhere*/ -getconnected:function(wirelist,wire){ - for(var i=0;i<wirelist.length;i++){ - for(var j=0;j<wirelist[i].length;j++){ - for(var k=0;k<wire.length;k++){ - if(this.ispoint(wirelist[i][j],wire[k])){ - return i; - } - } - } - } - return -1; -}, - -//returns points connected by lines -//it is recursive and should be called with NULL for wires -followwires:function(wires,pin){ - if(wires==null)wires=[]; - var points=[]; - points.push(pin); - var lines =webtronics.circuit.getwithselector('#webtronics_drawing > line, #information > .webtronics_namewire_connector'); - for(var i =0 ;i<lines.length;i++){ - var point1={x:lines[i].getAttribute('x1')-0,y:lines[i].getAttribute('y1')-0}; - var point2={x:lines[i].getAttribute('x2')-0,y:lines[i].getAttribute('y2')-0}; - if(wires.indexOf(lines[i])<0){ - if(this.ispoint(point1,pin)){ - wires.push(lines[i]); - var p=this.followwires(wires,point2); - for(var j=0;j<p.length;j++)points.push(p[j]); - } - else if(this.ispoint(point2,pin)){ - wires.push(lines[i]); - var p=this.followwires(wires,point1); - for(var j=0;j<p.length;j++)points.push(p[j]); - } -} -} -return points; -}, - - - -//sets the node numbers for parts -numberwires:function(parts){ - var analogpoints=[]; - var digitalpoints=[]; - for(var i=0;i<parts.length; i++){ - //analog node numbering loop - if(parts[i].type=="wire")continue; - - if( parts[i].type=="gnd"){ - if (analogpoints.length==0 ){ - var wire=this.followwires(null,{x:parts[i].analogpins[0]['x'],y:parts[i].analogpins[0]['y']}); - analogpoints.push(wire); -//add this node to thelist of digital wires -digitalpoints.push(wire); -} -parts[i].analogpins[0]["node"]=0; -// parts[i].digitalpins[0]["node"]=0; -continue; -} -if(parts[i].analogpins!=undefined){ - for(var j=0;j<parts[i].analogpins.length;j++){ - var wire=this.followwires(null,{x:parts[i].analogpins[j]['x'],y:parts[i].analogpins[j]['y']}); - var found=this.getconnected(analogpoints,wire); - if(found<0){ - analogpoints.push(wire); - parts[i].analogpins[j]["node"]=analogpoints.length-1; - } - else{ - parts[i].analogpins[j]["node"]=found; - } - } -} - //digital node numbering loop - - if(parts[i].digitalpins!=undefined){ - for(var j=0;j<parts[i].digitalpins.length;j++){ - var wire=this.followwires(null,{x:parts[i].digitalpins[j]['x'],y:parts[i].digitalpins[j]['y']}); - var found=this.getconnected(digitalpoints,wire); - if(found<0){ - digitalpoints.push(wire); - parts[i].digitalpins[j]["node"]=digitalpoints.length-1; - } - else{ - parts[i].digitalpins[j]["node"]=found; - } - } - } - } - //returns true if digital and analog are mixed - return this.mixedsignals(analogpoints,digitalpoints); -} , - - - -/* creates all netlist data from parts data*/ -getnodes:function(parts){ - var sections={netlist:[],coupling:[],firstdir:[],simulation:[],lastdir:[]}; - - //if(this.numberwires(parts))return {firstdir:[],netlist:[{error:"pin is both analog and digital"}],lastdir:[],plot:[]}; - this.numberwires(parts); - for(var i=0;i<parts.length; i++){ - // if(parts[i].type=="wire")continue; - // check what type of simulation to use - if(parts[i].type=='gnd' || parts[i].type=='wire')continue; - if(parts[i].type=="plot"){ - if(sections.simulation.length==0){ - sections.simulation.push(".op"); - sections.simulation.push(".print tran"); - } - if(sections.simulation[1] !=undefined && sections.simulation[1].match(/\.print\sac/g)==null){ - sections.simulation[1]+=" v("+parts[i].analogpins[0]["node"]+")"; - sections.simulation[1]+=" "+parts[i].measure; - if(parts[i].model)sections.simulation.push(parts[i].model); - } - - - } - else{ - if(parts[i].type=="v"){ - if(sections.simulation.length==0 && parts[i].model.length){ - sections.simulation.push(".op"); - sections.simulation.push(".print ac "+parts[i].measure); - sections.simulation.push(parts[i].model); - } - } - else if(parts[i].type=="l"){ - if(parts[i].model.length){ - sections.coupling.push(parts[i].model); - } - } - else{ - if(parts[i].model.match(/\.mod/i) && !parts[i].id.match(/^x/))parts[i].id="x"+parts[i].id; - if(parts[i].model.length)sections.firstdir.push(parts[i].model); - - } - //create pins array - var net={error:parts[i].error,pwlval1:parts[i].pwlval1,pwlval2:parts[i].pwlval2,pwlval3:parts[i].pwlval3,pwlval4:parts[i].pwlval4,pwlval5:parts[i].pwlval5,pwlval6:parts[i].pwlval6,pwlval7:parts[i].pwlval7,pwlval8:parts[i].pwlval8,pulval1:parts[i].pulval1,pulval2:parts[i].pulval2,pulval3:parts[i].pulval3,pulval4:parts[i].pulval4,pulval5:parts[i].pulval5,pulval6:parts[i].pulval6,pulval7:parts[i].pulval7,name:parts[i].name, - partid:parts[i].id,pins:{analog:parts[i].analogpins,digital:parts[i].digitalpins},model:parts[i].value,amplitude:parts[i].amplitude, - phase:parts[i].phase, risedelay:parts[i].risedelay, inputload:parts[i].inputload, falldelay:parts[i].falldelay, offsetvoltage:parts[i].offsetvoltage,voltageamplitude:parts[i].voltageamplitude,frequency:parts[i].frequency, - delaytime:parts[i].delaytime,dampingfactor:parts[i].dampingfactor,eval1:parts[i].eval1,eval2:parts[i].eval2,eval3:parts[i].eval3,eval4:parts[i].eval4,eval5:parts[i].eval5,eval6:parts[i].eval6}; - if(net!=null)sections.netlist.push(net); - } - - } - - return sections; -}, - -/* organizes data into netlist*/ -createnetlist:function(responsefunc){ - - var parts=webtronics.circuit.getwithselector('#webtronics_drawing > g'); - - if(parts.length<1){ - responsefunc("no parts found \n"); - return; - } - - - - var partswtx=this.sortnetlist(this.getwtxdata(parts)); - - - if(partswtx[0].type.toLowerCase()!='gnd'){ - responsefunc('no ground node'); - return; - } - this.connectnamewires(partswtx); - - var spice="*ngspice netlist * \n"; - var sections=this.getnodes(partswtx); - - //dump models into spice - - if(sections.netlist.length){ - var command=""; - for(var i=0;i<sections.netlist.length;i++){ - if(sections.netlist[i].error!=""){ - spice+=sections.netlist[i].error+'\n'; - continue; - } - command=sections.netlist[i].partid; - var pins=[]; - for(var j=0;j<sections.netlist[i].pins['analog'].length;j++)pins.push(sections.netlist[i].pins['analog'][j]); - for(var j=0;j<sections.netlist[i].pins['digital'].length;j++)pins.push(sections.netlist[i].pins['digital'][j]); - pins.sort(function(a,b){return a.index > b.index? 1:a.index < b.index?-1:0;}) -// console.log(pins); -for(var j=0;j<pins.length;j++){command += " "+pins[j].node;} - - if(sections.netlist[i].name=="ac"){ - command+=" "+"AC "+sections.netlist[i].amplitude+" "+sections.netlist[i].phase; - }else if(sections.netlist[i].name=="sinvoltagesource"){ - command+=" "+"SIN ("+sections.netlist[i].offsetvoltage+" "+sections.netlist[i].voltageamplitude+" "+sections.netlist[i].frequency+" "+sections.netlist[i].delaytime+" "+sections.netlist[i].dampingfactor+")"; - }else if(sections.netlist[i].name=="battery"){ - command+=" "+"DC "+sections.netlist[i].model; -}else if(sections.netlist[i].name=="current"){ - command+=" "+"dc "+sections.netlist[i].model; -}else if(sections.netlist[i].name=="pulse"){ - command+=" "+"PULSE ("+sections.netlist[i].pulval1+" "+sections.netlist[i].pulval2+" "+sections.netlist[i].pulval3+" "+sections.netlist[i].pulval4+" "+sections.netlist[i].pulval5+" "+sections.netlist[i].pulval6+" "+sections.netlist[i].pulval7+")"; -} -else if(sections.netlist[i].name=="pwl"){ - command+=" "+"PWL ("+sections.netlist[i].pwlval1+" "+sections.netlist[i].pwlval2+" "+sections.netlist[i].pwlval3+" "+sections.netlist[i].pwlval4+" "+sections.netlist[i].pwlval5+" "+sections.netlist[i].pwlval6+" "+sections.netlist[i].pwlval7+" "+sections.netlist[i].pwlval8+")"; -} -else if(sections.netlist[i].name=="exponential"){ - command+=" "+"EXP ("+sections.netlist[i].eval1+" "+sections.netlist[i].eval2+" "+sections.netlist[i].eval3+" "+sections.netlist[i].eval4+" "+sections.netlist[i].eval5+" "+sections.netlist[i].eval6+")"; -} -else if(sections.netlist[i].name=="and"){ - command+=" "+sections.netlist[i].risedelay+" "+sections.netlist[i].falldelay; -} -else{ - command+=" "+sections.netlist[i].model; -} -if(command!="")spice+=command+'\n'; -} -} - -if(sections.coupling.length){ - for(var i=0;i<sections.coupling.length;i++){ - spice+=sections.coupling[i]+'\n'; - } -} - - -var modelloader={ - modeltext:"", - modelcount:0, - download:function(name){ - var found=false; - for( var i=0;i<webtronics.partslists.length;i++){ - - if(JSON.stringify(webtronics.partslists[i]).indexOf(name)!=-1){ - found=true; - if(webtronics.partslists[i].url.indexOf("http://")==-1){//see if path is local - - openfile( webtronics.partslists[i].url+"/spice/"+ name,this.responder); - } - else{ - server.requestfile(list.url,this.responder); - } - break; - this.modelcount++; - } - - } - if(!found)console.log("model not found"); - }, - finish:function(){ - spice+=modelloader.modeltext; - if(sections.simulation.length){ - for(var i=0;i<sections.simulation.length;i++){ - if(sections.simulation[i]!="")spice+=sections.simulation[i]+"\n"; - } - } - if(sections.lastdir.length){ - sections.lastdir=sections.lastdir.uniq(); - for(var i=0;i<sections.lastdir.length;i++){ - if(sections.lastdir[i]!="")spice+=sections.lastdir[i]+"\n"; - } - } - responsefunc(spice); - }, - - responder:function(text){ - console.log("reponded"); - modelloader.modeltext+=text; - if(!modelloader.modelcount){ - modelloader.finish(); - spice=spice.concat(".end \n"); - - } - } -} - - -if(sections.firstdir.length){ - sections.firstdir=sections.firstdir.uniq(); - - for(var i=0;i<sections.firstdir.length;i++){ -// console.log(sections.firstdir[i]); - -if(sections.firstdir[i].length){ - - - - modelloader.download(sections.firstdir[i],sections,webtronics.partslists); -} -} -} -else modelloader.finish(); -var connector=webtronics.circuit.getwithselector('#information > .webtronics_namewire_connector') -for(var i=0;i<connector.length;i++)connector[i].parentNode.removeChild(connector[i]); - - - -}, - - - - - -writeconnects:function(pins){ - - var str=[]; - - for(var i=0;i<pins.length;i++){ - str[i] = pins[i].x +','+pins[i].y; - } - return str.join(';'); -}, - - -getconnects:function(elem){ - var pins=[]; - var nodes = this.getwtxtagname(elem,"node"); - for(var j=0;j<nodes.length;j++){ -// console.log(nodes[j]); -// console.log(this.parseMatrix(elem)); -var point = this.matrixxform( {x:this.getwtxattribute(nodes[j],"x"),y:this.getwtxattribute(nodes[j],"y")},this.parseMatrix(elem)); -pins.push({x:point.x,y:point.y}) ; -} - //sort nodes int correct order - return pins; - }, - - isconnect:function(pin,radius,x,y){ - return (Math.abs(pin.x-x)<3)&&(Math.abs(pin.y-y)<3); - }, - - isconnects:function(parts,radius,x,y){ - - for(var i=0; i<parts.length; i++){ - if(parts[i].tagName =='g'){ - var pins=this.getconnects(parts[i]); - if(pins){ - for(var j=0;j<pins.length;j++){ - if(this.isconnect(pins[j],radius,x,y)){ - return pins[j]; - } - } - } - } - } - return null; - }, - -//get the number by part id and leg -getnodenumber:function(name, leg){ - //get part by id - var part=webtronics.circuit.getwithselector("#webtronics_drawing wtx:id "+name )[0]; - var nodes=part.getwtxtagname("node"); - for(var i=0;i<nodes.length;i++){ - if(nodes[i].getAttribute("index")==leg){ - var wire = this.followwires(null,{ x:this.getwtxattribute(node,"x"),y:this.getwtxattribute(node,"y")}); - return this.getconnected(analogwires,wire); - } - } - return -1 -}, -getwtxtagname:function(elem,tagname){ - - - var tag=elem.getElementsByTagName("wtx:"+tagname); - if(!tag.length){ - tag=elem.getElementsByTagName(tagname); - } - if(!tag.length){ - tag=elem.getElementsByTagNameNS(this.wtxNs,tagname); - } - if(!tag.length){ - tag=elem.getElementsByTagNameNS("*",tagname); - } - return tag; - -}, - -getwtxattribute:function(elem,attrib){ - var value=elem.getAttribute(attrib); - if(value==undefined)value=elem.getAttributeNS(this.wtxNs,attrib); - if(value==undefined)value=elem.getAttributeNS("*",attrib); - - return value; -}, - -readwtx:function(elem,value){ - var tag=this.getwtxtagname(elem,value); - if(tag[0])return tag[0].textContent; - else return ""; -}, - -writewtx:function(elem,value,text){ - var tag=this.getwtxtagname(elem,value); - if(tag[0])tag[0].textContent=text; -}, - - - -} diff --git a/views/script/savenetlist.js b/views/script/savenetlist.js index 7d598a4..baf494f 100644 --- a/views/script/savenetlist.js +++ b/views/script/savenetlist.js @@ -170,7 +170,17 @@ jQuery(function(){ }); +var savedacval3=""; +var savedacval2=""; +var savedacval1=""; +var saveddcval1=""; +var saveddcval2=""; +var saveddcval3=""; + +var savedtransval1=""; +var savedtransval2=""; +var savedtransval3=""; /*------------------------------------------------------------------------------------------------------------------------------------------------ Ac netlist variable for ac @@ -215,9 +225,7 @@ if(stop_ac_unit==""){ } }); -var savedacval3=""; -var savedacval2=""; -var savedacval1=""; + jQuery("#frequency_selectbox").change(function(){ freq = jQuery(this).val(); @@ -345,9 +353,6 @@ if(stop_dc_unit==""){ } }); -var saveddcval1=""; -var saveddcval2=""; -var saveddcval3=""; jQuery("#start_volt_selectbox").change(function(){ @@ -374,7 +379,7 @@ jQuery("#start_volt_selectbox").change(function(){ start_dc_unit = "12"; } saveddcval1=start_dc_unit; - //console.log(start_dc_unit); + console.log(start_dc_unit); }); jQuery("#inc_volt_selectbox").change(function(){ @@ -403,7 +408,7 @@ jQuery("#inc_volt_selectbox").change(function(){ increment_dc_unit = "12"; } saveddcval2=increment_dc_unit; - //console.log(increment_dc_unit); + console.log(increment_dc_unit); }); jQuery("#stop_volt_selectbox").change(function(){ @@ -432,7 +437,7 @@ jQuery("#stop_volt_selectbox").change(function(){ stop_dc_unit = "12"; } saveddcval3=stop_dc_unit; - //console.log(stop_dc_unit); + console.log(stop_dc_unit); }); @@ -482,9 +487,6 @@ if(stop_trans_unit==""){ }); -var savedtransval1=""; -var savedtransval2=""; -var savedtransval3=""; jQuery("#start_time_selectbox").change(function(){ trans_start_time = jQuery(this).val(); @@ -506,7 +508,7 @@ jQuery("#start_time_selectbox").change(function(){ start_trans_unit = "12"; } savedtransval1=start_trans_unit; - //console.log(start_trans_unit); + console.log(start_trans_unit); }); jQuery("#step_time_selectbox").change(function(){ @@ -530,7 +532,7 @@ jQuery("#step_time_selectbox").change(function(){ step_trans_unit = "12"; } savedtransval2=step_trans_unit; - //console.log(step_trans_unit); + console.log(step_trans_unit); }); jQuery("#stop_time_selectbox").change(function(){ @@ -554,11 +556,13 @@ jQuery("#stop_time_selectbox").change(function(){ stop_trans_unit = "12"; } savedtransval3=stop_trans_unit; - //console.log(stop_trans_unit); + console.log(stop_trans_unit); }); + + }); diff --git a/views/script/savenetlist.js~ b/views/script/savenetlist.js~ deleted file mode 100644 index 1bfa721..0000000 --- a/views/script/savenetlist.js~ +++ /dev/null @@ -1,566 +0,0 @@ -jQuery(document).ready(function(){ - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -For Simulation of Netlist and Removal of netlist Window -------------------------------------------------------------------------------------------------------------------------------------------------*/ - - jQuery("#webtronics_netlist_simulate").click(function(){ - console.log("simulation button clicked"); - jQuery('#webtronics_netlist_text_div').hide(); - jQuery('#webtronics_netlist_buttons').hide(); - jQuery('#webtronics_netlist_text').hide(); - jQuery('#webtronics_disable').hide(); - - - - - - jQuery.ajax({ - - url: "/eSIM/simulation.php", - type: "POST", - data: {netlist:jQuery("#webtronics_netlist_text_area").val()}, - dataType: "html", - - /* - type: "POST", - url: "/eSIM/simulation.php", - data: '$image,$image1', - success:function(phpData){ - alert(phpData); - }*/ - - - - - success:function() { - - //console.log(data); - //window.location = "/eSIM/simulation.php"; - window.open('/eSIM/simulation.php','about:blank','scrollbars=auto , scrollbars=1, left=300,top=50,width=800,height=600,toolbar=0,resizable=0'); - //alert (); - //if( data == 'fail' ) { - //console.log("nahi hua bc"); - //} - - // else if (data = 'success') { - //console.log("ho gaya bc"); - //} -}, - - - }); - - - }); - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -VIEW NETLIST WINDOW -------------------------------------------------------------------------------------------------------------------------------------------------*/ - -jQuery("#webtronics_netlist").click(function(){ - - jQuery('#webtronics_netlist_text_div').show(); - jQuery('#webtronics_netlist_buttons').show(); - jQuery('#webtronics_netlist_text').show(); - jQuery('#webtronics_disable').show(); - - - }); - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -For Download of netlist -------------------------------------------------------------------------------------------------------------------------------------------------*/ - - jQuery("#webtronics_netlist_text_download").click(function(){ - //console.log("button clicked"); - - jQuery.ajax({ - - url: "/eSIM/download.php", - - type: "POST", - data: {netlist:jQuery("#webtronics_netlist_text_area").val()}, - dataType: "html", - - /* success: function() { - console.log("success"); - } - - */ - success: function() { - //console.log(data); - window.location = "/eSIM/download.php" ; - //if( data == 'fail' ) { - //console.log("nahi hua "); - //} - - // else if (data = 'success') { - //console.log("ho gaya "); - //} -}, - - - }); - - - }); - - - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -DC FUNCTIONALITY IS WRITTEN HERE ----------------------------------------------------------------------------------------------------------------------------------------------------*/ -jQuery(function(){ - jQuery("#dc_menu").hide(); - jQuery("#ac_menu").hide(); - jQuery("#transient_menu").hide(); - jQuery("#analysis_selectbox").change(function(){ - if (jQuery(this).val() == "1") - { - jQuery("#dc_menu").show(); - jQuery("#ac_menu").hide(); - jQuery("#transient_menu").hide(); - } - else if (jQuery(this).val() == "2") - { - jQuery("#ac_menu").show(); - jQuery("#dc_menu").hide(); - jQuery("#transient_menu").hide(); - } - else if (jQuery(this).val() == "3") - { - jQuery("#transient_menu").show(); - jQuery("#dc_menu").hide(); - jQuery("#ac_menu").hide(); - - } - - //$("#preview").change(function(){ - //jQuery"#analysis_selectbox".val(); - //$("#div1, #div2").toggle(); - }); -}); - - - -jQuery("#analysis_selectbox").change(function(){ - - analysis_type = jQuery(this).val(); - //console.log(analysis_type); -}); - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -Ac netlist variable for ac -------------------------------------------------------------------------------------------------------------------------------------------------*/ - -jQuery("#saveac").click(function(){ - - startfreq = jQuery("#startfreqval").val(); - stopfreq = jQuery("#stopfreqval").val(); - noofpoint = jQuery("#noofpointsval").val(); - //console.log(startfreq,stopfreq,noofpoint); - //console.log(startfreq); - if (startfreq == "") - { - alert("Please enter Start Frequency"); - } - else if (stopfreq == "") - { - alert("Please enter Stop Frequency value"); - } - else if (noofpoint == "") - { - alert("Please Enter No Of Points"); - } -}); - - -jQuery("#frequency_selectbox").change(function(){ - - freq = jQuery(this).val(); - //console.log(freq); -}); - -jQuery("#scale_selectbox").change(function(){ - scale = jQuery(this).val(); - - if (scale == "1") - { - scale_val = "lin"; - } - else if (scale == "2") - { - scale_val = "dec"; - } - else if (scale == "3") - { - scale_val = "octal"; - } -}); - -jQuery("#start_frequency_selectbox").change(function(){ - - ac_start_freq = jQuery(this).val(); - - if (ac_start_freq == "1") - { - start_ac_unit = "Hz"; - } - else if (ac_start_freq == "2") - { - start_ac_unit = "THz"; - } - if (ac_start_freq == "3") - { - start_ac_unit = "GHz"; - } - else if (ac_start_freq == "4") - { - start_ac_unit = "Meg"; - } - else if (ac_start_freq == "5") - { - start_ac_unit = "KHz"; - } - -}); - -jQuery("#stop_frequency_selectbox").change(function(){ - - ac_stop_freq = jQuery(this).val(); - - if (ac_stop_freq == "1") - { - stop_ac_unit = "Hz"; - } - else if (ac_stop_freq == "2") - { - stop_ac_unit = "THz"; - } - if (ac_stop_freq == "3") - { - stop_ac_unit = "GHz"; - } - else if (ac_stop_freq == "4") - { - stop_ac_unit = "Meg"; - } - else if (ac_stop_freq == "5") - { - stop_ac_unit = "KHz"; - } - -}); - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -Dc netlist variable for dc -------------------------------------------------------------------------------------------------------------------------------------------------*/ -jQuery("#savedc").click(function(){ - - source = jQuery("#sourceval").val(); - start = jQuery("#startval").val(); - increment = jQuery("#Incrementval").val(); - stop = jQuery("#stopval").val(); - //console.log(source,start,increment,stop); - //console.log(start); - if (source == "") - { - alert("Please enter Source Name"); - } - else if (start == "") - { - alert("Please enter Start Time"); - } - else if (increment == "") - { - alert("Please enter the increment value"); - } - else if (stop == "") - { - alert("Please enter the Stop Time"); - } - -}); - - -jQuery("#start_volt_selectbox").change(function(){ - - dc_start_time = jQuery(this).val(); - - if (dc_start_time == "1") - { - start_dc_unit = "00"; - } - else if (dc_start_time == "2") - { - start_dc_unit = "03"; - } - if (dc_start_time == "3") - { - start_dc_unit = "06"; - } - else if (dc_start_time == "4") - { - start_dc_unit = "09"; - } - else if (dc_start_time == "5") - { - start_dc_unit = "12"; - } - - //console.log(start_dc_unit); -}); - -jQuery("#inc_volt_selectbox").change(function(){ - - - dc_increment_time = jQuery(this).val(); - - if (dc_increment_time == "1") - { - increment_dc_unit = "00"; - } - else if (dc_increment_time == "2") - { - increment_dc_unit = "03"; - } - if (dc_increment_time == "3") - { - increment_dc_unit = "06"; - } - else if (dc_increment_time == "4") - { - increment_dc_unit = "09"; - } - else if (dc_increment_time == "5") - { - increment_dc_unit = "12"; - } - - //console.log(increment_dc_unit); -}); - -jQuery("#stop_volt_selectbox").change(function(){ - - - dc_stop_time = jQuery(this).val(); - - if (dc_stop_time == "1") - { - stop_dc_unit = "00"; - } - else if (dc_stop_time == "2") - { - stop_dc_unit = "03"; - } - if (dc_stop_time == "3") - { - stop_dc_unit = "06"; - } - else if (dc_stop_time == "4") - { - stop_dc_unit = "09"; - } - else if (dc_stop_time == "5") - { - stop_dc_unit = "12"; - } - - //console.log(stop_dc_unit); -}); - - - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -netlist variable for transient -------------------------------------------------------------------------------------------------------------------------------------------------*/ -jQuery("#savetransient").click(function(){ - - start_trans = jQuery("#start_time").val(); - step_trans = jQuery("#step_time").val(); - stop_trans = jQuery("#stop_time").val(); - //console.log(start_trans, step_trans, stop_trans); - console - - if (start_trans == "") - { - alert("Please enter Start Time") - } - else if (step_trans == "") - { - alert("Please enter Step Time"); - } - else if (stop_trans == "") - { - alert("Please enter the Stop Time"); - } - -}); - - -jQuery("#start_time_selectbox").change(function(){ - - trans_start_time = jQuery(this).val(); - - if (trans_start_time == "1") - { - start_trans_unit = "03"; - } - else if (trans_start_time == "2") - { - start_trans_unit = "06"; - } - if (trans_start_time == "3") - { - start_trans_unit = "09"; - } - else if (trans_start_time == "4") - { - start_trans_unit = "12"; - } - - //console.log(start_trans_unit); -}); - -jQuery("#step_time_selectbox").change(function(){ - - trans_step_time = jQuery(this).val(); - - if (trans_step_time == "1") - { - step_trans_unit = "03"; - } - else if (trans_step_time == "2") - { - step_trans_unit = "06"; - } - if (trans_step_time == "3") - { - step_trans_unit = "09"; - } - else if (trans_step_time == "4") - { - step_trans_unit = "12"; - } - - console.log(step_trans_unit); -}); - -jQuery("#stop_time_selectbox").change(function(){ - - trans_stop_time = jQuery(this).val(); - - if (trans_stop_time == "1") - { - stop_trans_unit = "03"; - } - else if (trans_stop_time == "2") - { - stop_trans_unit = "06"; - } - if (trans_stop_time == "3") - { - stop_trans_unit = "09"; - } - else if (trans_stop_time == "4") - { - stop_trans_unit = "12"; - } - - console.log(stop_trans_unit); -}); - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -Netlist Generation -------------------------------------------------------------------------------------------------------------------------------------------------*/ -change_val = "0"; -Flag = ""; - //console.log("out") - //console.log(change_val) - jQuery("#webtronics_netlist_generate").click(function(){ - //console.log(change_val) - - if (change_val == "0") - { - Flag = jQuery("#webtronics_netlist_text_area").val(); - //console.log("if when 0") - - -/*------------------------------------------------------------------------------------------------------------------------------------- - Here are the conditions concatenated to give final netlist values for dc all cases ----------------------------------------------------------------------------------------------------------------------------------------------*/ - if (analysis_type == "1") - { - //console.log(jQuery("#analysis_selectbox").val()); - - jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".dc" + " " + source + " " + start + "e" + "-" + start_dc_unit + " " + stop + "e" + "-" + stop_dc_unit + " " + increment + "e" + "-" + increment_dc_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" ); - - change_val = "1"; - //console.log(jQuery("#analysis_selectbox").val()); - } - - -/*------------------------------------------------------------------------------------------------------------------------------------------------ -Here are the all AC Cases for generating final netlist values -------------------------------------------------------------------------------------------------------------------------------------------------*/ - else if (analysis_type == "2") - { - jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".ac" + " " + scale_val + " " + noofpoint + " " + startfreq + start_ac_unit + " " + stopfreq + stop_ac_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" ); - - change_val = "1"; - } -/*------------------------------------------------------------------------------------------------------------------------------------------------ -Here are the all Transiet Cases for generating final netlist values -------------------------------------------------------------------------------------------------------------------------------------------------*/ - //else if (analysis_type == "3" && time == "1") - else if (analysis_type == "3") - { - jQuery("#webtronics_netlist_text_area").val(Flag + '\n' + ".tran" + " " + step_trans + "e" + "-" + step_trans_unit + " " + stop_trans + "e"+ "-" + stop_trans_unit + " " + start_trans + "e" + "-" + start_trans_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n" +".end \n" ); - - change_val = "1"; - } - - -} - -else if( change_val == "1") - -{ - //console.log(change_val) - jQuery("#webtronics_netlist_text_area").val(""); - //console.log("if when 1") - - if (analysis_type == "1") - - { - - - jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".dc" + " " + source + " " + start + "e" + "-" + start_dc_unit + " " + stop + "e" + "-" + stop_dc_unit + " " + increment + "e" + "-" + increment_dc_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" ); - change_val = "1"; - } - - - - else if (analysis_type == "2") - { - jQuery("#webtronics_netlist_text_area").val(Flag + '\n'+ ".ac" + " " + scale_val + " " + noofpoint + " " + startfreq + start_ac_unit + " " + stopfreq + stop_ac_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n"+ ".end \n" ); - - change_val = "1"; - } - - - else if (analysis_type == "3") - { - jQuery("#webtronics_netlist_text_area").val(Flag + '\n' + ".tran" + " " + step_trans + "e" + "-" + step_trans_unit + " " + stop_trans + "e"+ "-" + stop_trans_unit + " " + start_trans + "e" + "-" + start_trans_unit + '\n' + '\n'+ ".control \n"+ "run \n"+ "print allv > dumpv.txt \n" + "print alli > dumpi.txt \n" + ".endc \n" +".end \n" ); - - change_val = "1"; - } - - -} - - -}); -}); - diff --git a/views/script/schematic.js b/views/script/schematic.js index 016116a..6961806 100644 --- a/views/script/schematic.js +++ b/views/script/schematic.js @@ -308,6 +308,12 @@ Schematic.prototype.showbackground=function(){ }
}
}
+
+SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(toElement) {
+ return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM());
+};
+
+
Schematic.prototype.parseMatrix=function(group){
var matrix={a:1,b:0,c:0,d:1,e:0,f:0};
diff --git a/views/style/schematic.css b/views/style/schematic.css index 2cd7ae3..844e220 100644 --- a/views/style/schematic.css +++ b/views/style/schematic.css @@ -276,8 +276,9 @@ float:left; #webtronics_netlist_text>*{ float:left; } + #webtronics_netlist_text_div{ - overflow:hide; + overflow:auto; } #webtronics_image{ diff --git a/views/style/schematic.css~ b/views/style/schematic.css~ deleted file mode 100644 index 9502122..0000000 --- a/views/style/schematic.css~ +++ /dev/null @@ -1,439 +0,0 @@ -.normal_button { - padding:2px; - border-style:solid; - border-width:2px; - border-color:black; - background-color:#e7e7e7; - border-radius:6px; - } - -.pressed_button { - padding:2px; - border-style:solid; - border-width:2px; - border-color:#000000; - background-color:#bfbfbf; - border-radius:6px; - } - -.normal_button:hover{ - padding:2px; - border-style:solid; - border-width:2px; - border-color:#000000; - background-color:#ffffff; - border-radius:6px; -} - - - -#webtronics_file{ - position :relative; - float:left; - height:32px; - margin:8px; - padding:2px; - border-style:solid; - border-width:2px; - border-color:#000000; - background-color:#FFFAF0; - border-radius:6px; -} -#webtronics_file *{ - float:left; -} - -.webtronics_menu{ - position:absolute; - padding:2px; - border-style:solid; - border-width:2px; - border-color:black; - background-color:#e7e7e7; - cursor:pointer; -} -.webtronics_menu>p:hover{ - background-color:#ffffff; - -} - - -div#webtronics_main_window{ - - font-family:verdana,arial; - font-size:10pt; - height:100%; - background-color:#e7e7e7; - border:2px solid #e7e7e7; - -} - -#webtronics_diagram_area>iframe{ - position:absolute; - overflow:hidden; - height:100%; - width:100%; - background-color:#e7e7e7; - border-width: 0px; - margin: 0px; - padding: 0px; - -moz-user-select:none; - -webkit-user-select:none; - -ms-user-select:none; -} - -/*list menu */ -div#webtronics_center{ - position:relative; - overflow:hidden; - background-color:inherit; - border:2px solid #000000; -} -/* tabs */ -div#webtronics_tab_area{ - position:relative; - float:left; - height: 32px; - background-color: #e7e7e7; -} - - -div.webtronics_tab{ - position:relative; - float:left; - overflow:hidden; - height:30px; - border-style:solid; - border-width:2px; - border-color:black; - border-top-left-radius:6px; - border-top-right-radius:6px; - background-color:#bfbfbf; - -} -div.webtronics_selected_tab{ - position:relative; - float:left; - overflow:hidden; - height:30px; - border-style:solid; - border-width:2px; - border-color:black; - border-top-left-radius:6px; - border-top-right-radius:6px; - background-color:inherit; - -} - -div#webtronics_new_tab{ - position:relative; - float:left; - height:30px; - border-style:solid; - border-width:2px; - border-color:black; - border-radius:6px; - background-color:#bfbfbf; -} - -div.webtronics_close_tab{ - position:relative; - float:right; - border-style:solid; - border-width:2px; - border-color:black; - border-radius:6px; - background-color:#bfbfbf; -} - -div#webtronics_side_bar{ - position:relative; - float:left; - width: 132px; - overflow: hidden; - border-style:solid; - border-width:2px; - border-color:black; -} - -div#webtronics_parts_list{ - position:relative; - left:0; - top:0; - width:132px; - display:block; - height:auto; - overflow:auto; -} - -div#webtronics_parts_list p{ - cursor:pointer; -} - - - -div#webtronics_parts_list>div div{ - display:none; - background-color:#ffffff; - cursor:pointer; -} - -div#webtronics_parts_list>div{ - background-color:#cfcfcf; - border-style:solid; - border-width:2px; - border-color:black; -} - -div#webtronics_parts_list>div>p:hover{ - background-color:#ffffff; -} - -div#webtronics_parts_list *{ - margin:0px; - -moz-user-select:none; - -webkit-user-select:none; - -ms-user-select:none; -} - - - -fieldset { - float:left; - margin-left:12px; - padding:0px; -} - - - -div#webtronics_toolbar{ - height:60px; - width:100%; - border-style:solid; - border-width:2px; - border-color:#000000; - overflow:hidden; - -moz-user-select:none; - -webkit-user-select:none; - -ms-user-select:none; - } - - - -/*popups*/ -div.modal{ - display:none; - position:absolute; - left:200px; - top:10px; - border-style: solid; - border-radius:20px; - background-color:inherit; - padding: 5px; -} -div.modal>*{ - float:left; -} -#webtronics_properties_buttons{ - clear:left; -} - -#webtronics_netlist_buttons{ - clear:left; -} - - -.webtronics_help{ - float:right; - border-style: solid; - border-color:#000000; - background-color:#000000; - color:#ffffff; - padding: 5px; - display:none; -} - - -#webtronics_chips_box>*{ -float:left; -} - -#webtronics_netlist_text>*{ -float:left; -} -#webtronics_netlist_text_div{ - overflow:hide; -} - -#webtronics_image{ - width:340px; - height:360px; - border:1px solid black; - background-color:#e7e7e7; - overflow:hide; -} -/*display areas*/ - - - -#webtronics_image_div{ - width:100%; - height:80%; - border:1px solid black; - background-color:#e7e7e7; - overflow:auto; -} -#webtronics_image_div>img{ - max-width:300px; - max-height:280px; - width:auto; - height:auto; -} - -#webtronics_diagram_area { - position:relative; - float:left; - overflow:hidden; - cursor:crosshair; - border:1px solid black; - background-color:#e7e7e7; - -moz-user-select:none; - -webkit-user-select:none; - -ms-user-select:none; - -} - -#webtronics_part_display{ - width:126px; - height:130px; - background-color:#ffffff; - border:2px solid black; - -moz-user-select:none; - -webkit-user-select:none; - -ms-user-select:none; - -} - - - -#webtronics_chip_display{ - width:200px; - height:200px; - border:1px solid black; - background-color:#ffffff; - overflow: auto; - } - -#webtronics_print_dir_field{ - display:none; - clear:right; -} - -div#webtronics_footer{ - float:left; - width:100%; - height:auto ; - background-color:inherit; - -moz-user-select:none; - -webkit-user-select:none; - -ms-user-select:none; -} -div#webtronics_disable{ - display:none; - position:absolute; - left:0; - top:0; - width:100%; - height:100%; - background: rgba(45,45,45,0.5) url(web.png) no-repeat; - background-size: 100% 100%; - -moz-user-select:none; - -webkit-user-select:none; - -ms-user-select:none; -} -div#webtronics_open_file{ - display:none; - overflow:hidden; - position:absolute; - left:200px; - top:10px; - border-style: none; - background-color:inherit; - padding: none; - } - -div#webtronics_open_file_selector{ - font-size:30pt; -} -/*menu style*/ - -div#webtronics_context_menu{ - display:none; - z-index:100; - position:absolute; - top:0; - left:0; - background-color:inherit; -} - -div#webtronics_context_menu .enabled,div#webtronics_file_menu .enabled{ - color:#000000; -} - -div#webtronics_context_menu .disabled,div#webtronics_file_menu .disabled{ - color:#bfbfbf; -} - -div#webtronics_context_menu .enabled:hover,div#webtronics_file_menu .enabled:hover{ - background-color:#bfbfbf; - color:#ffffff; -} - -#webtronics_scope_display>*{ - float:left; -} - -div#webtronics_scope_display_div{ - overflow:hidden; - width:480px; - height:360px; -} -#webtronics_scope_display_frame{ - overflow:hidden; - width:480px; - height:360px; - border-color:#000000; - border-width: 2px; -} - -div#webtronics_scope_display{ - width:540px; - height:auto; - overflow: hide; -} -div#webtronics_scope_status_bar{ - float:left; - width:100%; - height:auto ; - background-color:inherit; - -moz-user-select:none; - -webkit-user-select:none; - -ms-user-select:none; -} - - -#webtronics_risedelay{ - display:none; -} - -#webtronics_falldelay{ - display:none; -} - -#webtronics_inputload{ - display:none; -} - - - - diff --git a/views/webtronix_server/parts.json b/views/webtronix_server/parts.json index 6241db9..581f66d 100644 --- a/views/webtronix_server/parts.json +++ b/views/webtronix_server/parts.json @@ -10,12 +10,43 @@ "op-amp":{ "help":"ux + - v- out v+ model\n\ndirective = include model file", "values":{ - "lm324":["lm324.mod"], - "lm358":["lm358.mod"], - "741":["ua741.mod","lm741.mod"], - "tl084":["tl084.mod"] + "ua741":["ua741.sub"] } + }, + "scr":{ + "values":{ + "scr":["scr.sub"] + } + }, + "triac":{ + "values":{ + "triac":["triac.sub"] + } + + }, + "diac":{ + "values":{ + "diac":["diac.sub"] + } + + }, + "fulladder":{ + "values":{ + "full_adder":["full_adder.sub"] + } + + }, + "halfadder":{ + "values":{ + "half_adder":["half_adder.sub"] + } + } + + + + + }, "analogmodels":{ @@ -160,8 +191,6 @@ "help":"dx a k model\na=anode\nk=kathode" }, - "scr":{}, - "triac":{}, "zener":{} }, "switches":{ diff --git a/views/webtronix_server/spice/1N34A.lib b/views/webtronix_server/spice/1N34a.lib index e0d0ac6..1ec59ea 100644 --- a/views/webtronix_server/spice/1N34A.lib +++ b/views/webtronix_server/spice/1N34a.lib @@ -1,3 +1,2 @@ - .MODEL 1N34A D(bv=75 cjo=0.5e-12 eg=0.67 ibv=18e-3 + is=2e-7 rs=7 n=1.3 vj=0.1 m=0.27 ) diff --git a/views/webtronix_server/spice/diac.sub b/views/webtronix_server/spice/diac.sub new file mode 100644 index 0000000..7f28ecc --- /dev/null +++ b/views/webtronix_server/spice/diac.sub @@ -0,0 +1,15 @@ +* Subcircuit diac +.subckt diac 1 2 +* /opt/esim/src/subcircuitlibrary/diac/diac.cir +* u1 1 1 2 aswitch +* u2 1 1 2 aswitch +a1 1 (1 2) u1 +a2 1 (1 2) u2 +* Schematic Name: aswitch, NgSpice Name: aswitch +.model u1 aswitch(log=TRUE cntl_off=0.1 cntl_on=25 r_on=0.0125 r_off=1000000 ) +* Schematic Name: aswitch, NgSpice Name: aswitch +.model u2 aswitch(log=TRUE cntl_off=-0.1 cntl_on=-25 r_on=0.0125 r_off=1000000 ) + +* Control Statements + +.ends diac diff --git a/views/webtronix_server/spice/full_adder.sub b/views/webtronix_server/spice/full_adder.sub new file mode 100644 index 0000000..5f261f7 --- /dev/null +++ b/views/webtronix_server/spice/full_adder.sub @@ -0,0 +1,13 @@ +* Subcircuit full_adder +.subckt full_adder 8 7 5 4 1 +* eeschema netlist version 1.1 (spice format) creation date: wed jun 24 12:24:33 2015 +.include half_adder.sub +x1 8 7 6 2 half_adder +x2 5 6 4 3 half_adder +* u2 3 2 1 d_or +a1 [3 2 ] 1 u2 +* Schematic Name: d_or, NgSpice Name: d_or +.model u2 d_or(fall_delay=1.0e-9 input_load=1.0e-12 rise_delay=1.0e-9 ) +* Control Statements + +.ends full_adder
\ No newline at end of file diff --git a/views/webtronix_server/spice/half_adder.sub b/views/webtronix_server/spice/half_adder.sub new file mode 100644 index 0000000..e9f9222 --- /dev/null +++ b/views/webtronix_server/spice/half_adder.sub @@ -0,0 +1,14 @@ +* Subcircuit half_adder +.subckt half_adder 1 4 3 2 +* eeschema netlist version 1.1 (spice format) creation date: wed jun 24 11:31:48 2015 +* u2 1 4 3 d_xor +* u3 1 4 2 d_and +a1 [1 4 ] 3 u2 +a2 [1 4 ] 2 u3 +* Schematic Name: d_xor, NgSpice Name: d_xor +.model u2 d_xor(fall_delay=1.0e-9 input_load=1.0e-12 rise_delay=1.0e-9 ) +* Schematic Name: d_and, NgSpice Name: d_and +.model u3 d_and(fall_delay=1.0e-9 input_load=1.0e-12 rise_delay=1.0e-9 ) +* Control Statements + +.ends half_adder
\ No newline at end of file diff --git a/views/webtronix_server/spice/scr.sub b/views/webtronix_server/spice/scr.sub new file mode 100644 index 0000000..398c892 --- /dev/null +++ b/views/webtronix_server/spice/scr.sub @@ -0,0 +1,23 @@ +* Subcircuit scr +.subckt scr 3 7 1 +* /opt/esim/src/subcircuitlibrary/scr/scr.cir +.include PowerDiode.lib +* f2 +d1 5 2 PowerDiode +c1 3 9 10u +* f1 +v1 8 4 dc 0 +v2 6 5 dc 0 +* u1 9 1 6 aswitch +r1 7 8 50 +r2 3 9 1 +Vf2 2 3 0 +f2 3 9 Vf2 100 +Vf1 4 3 0 +f1 3 9 Vf1 10 +a1 9 (1 6) u1 +* Schematic Name: aswitch, NgSpice Name: aswitch +.model u1 aswitch(log=TRUE cntl_off=0.0 cntl_on=1.0 r_on=1.0 r_off=1.0e12 ) +* Control Statements + +.ends scr diff --git a/views/webtronix_server/spice/triac.sub b/views/webtronix_server/spice/triac.sub new file mode 100644 index 0000000..760908b --- /dev/null +++ b/views/webtronix_server/spice/triac.sub @@ -0,0 +1,32 @@ +* Subcircuit triac +.subckt triac 8 11 10 +* /opt/esim/src/subcircuitlibrary/triac/triac.cir +.include PowerDiode.lib +* f3 +v3 7 2 dc 0 +* f2 +v2 6 3 dc 0 +c1 8 9 10u +* f1 +v1 10 4 dc 0 +* u1 9 11 6 aswitch +* u2 9 2 11 aswitch +r1 8 9 1 +d1 5 8 PowerDiode +d2 1 7 PowerDiode +Vf3 1 8 0 +f3 8 9 Vf3 10 +Vf2 3 5 0 +f2 8 9 Vf2 10 +Vf1 4 8 0 +f1 8 9 Vf1 100 +a1 9 (11 6) u1 +a2 9 (2 11) u2 +* Schematic Name: aswitch, NgSpice Name: aswitch +.model u1 aswitch(log=TRUE cntl_off=0.1 cntl_on=1 r_on=0.0125 r_off=1000000 ) +* Schematic Name: aswitch, NgSpice Name: aswitch +.model u2 aswitch(log=TRUE cntl_off=-0.1 cntl_on=-1 r_on=0.0125 r_off=1000000 ) + +* Control Statements + +.ends triac diff --git a/views/webtronix_server/spice/ua741.sub b/views/webtronix_server/spice/ua741.sub new file mode 100644 index 0000000..ad26c00 --- /dev/null +++ b/views/webtronix_server/spice/ua741.sub @@ -0,0 +1,12 @@ +* Subcircuit ua741 +.subckt ua741 6 7 3 +* eeschema netlist version 1.1 (spice format) creation date: monday 17 december 2012 11:16:58 am ist +rout1 3 2 75 +eout1 2 0 1 0 1 +cbw1 1 0 31.85e-9 +rbw1 1 4 0.5e6 +ein1 4 0 7 6 100e3 +rin1 7 6 2e6 +* Control Statements + +.ends ua741
\ No newline at end of file diff --git a/views/webtronix_server/diodes/trigger.svg b/views/webtronix_server/subcircuits/diac.svg index 1970739..4645f95 100644 --- a/views/webtronix_server/diodes/trigger.svg +++ b/views/webtronix_server/subcircuits/diac.svg @@ -9,8 +9,8 @@ <g connects="0,10;40,10" stroke='black' stroke-width='2px' - id="D" - class="trigger"> + id="X" + class="diac"> <metadata class="part" > <wtx:part xmlns:wtx="/home/niel/Desktop/webtronics" > <wtx:pins> @@ -19,11 +19,11 @@ <wtx:node index="2" x="40" y="10"/> </wtx:analog> </wtx:pins> - <wtx:id>d</wtx:id> + <wtx:id>x</wtx:id> - <wtx:type>d</wtx:type> - <wtx:name>trigger</wtx:name> - <wtx:category>diodes</wtx:category> + <wtx:type>x</wtx:type> + <wtx:name>diac</wtx:name> + <wtx:category>subcircuits</wtx:category> <wtx:flip></wtx:flip> <wtx:value></wtx:value> <wtx:label></wtx:label> diff --git a/views/webtronix_server/subcircuits/diacsubcircuit.png b/views/webtronix_server/subcircuits/diacsubcircuit.png Binary files differnew file mode 100644 index 0000000..4230dad --- /dev/null +++ b/views/webtronix_server/subcircuits/diacsubcircuit.png diff --git a/views/webtronix_server/subcircuits/fulladder.svg b/views/webtronix_server/subcircuits/fulladder.svg new file mode 100644 index 0000000..c0a25b6 --- /dev/null +++ b/views/webtronix_server/subcircuits/fulladder.svg @@ -0,0 +1,46 @@ +<svg width="104" height="74" xmlns="http://www.w3.org/2000/svg"> + <!-- Created with Method Draw - http://github.com/duopixel/Method-Draw/ --> + <g id="X" + class="fulladder"> + + +<metadata class="part" > + <wtx:part xmlns:wtx="http://code.google.com/p/webtronics" > + <wtx:pins> + <wtx:analog> + <wtx:node index="1" x="0" y="19"/> + <wtx:node index="2" x="0" y="39"/> + <wtx:node index="3" x="0" y="59"/> + <wtx:node index="4" x="103" y="19"/> + <wtx:node index="5" x="103" y="59"/> + </wtx:analog> + </wtx:pins> + <wtx:id>x</wtx:id> + + <wtx:type>x</wtx:type> + <wtx:name>fulladder</wtx:name> + <wtx:category>subcircuits</wtx:category> + <wtx:flip></wtx:flip> + <wtx:value></wtx:value> + <wtx:label></wtx:label> + <wtx:spice></wtx:spice> + <wtx:model></wtx:model> + </wtx:part> +</metadata> + + + <rect id="svg_1" height="70" width="55" y="2.75" x="23.75" stroke-width="1.5" stroke="#000" fill="#fff"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_4" y2="18.75" x2="102.75" y1="18.75" x1="79.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_5" y2="19.75" x2="23.75" y1="19.75" x1="0.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_6" y2="57.75" x2="102.75" y1="57.75" x1="79.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_7" y2="38.75" x2="23.75" y1="38.75" x1="0.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_8" y2="58.75" x2="23.75" y1="58.75" x1="0.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <text style="cursor: move;" xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_9" y="24.75" x="26.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">IN1</text> + <text style="cursor: move;" xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_10" y="42.75" x="26.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">IN2</text> + <text xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_11" y="62.75" x="26.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">CIN</text> + <text xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_12" y="23.75" x="55.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">SUM</text> + <text style="cursor: move;" xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_13" y="62.75" x="51.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">COUT</text> + <text xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="8" id="svg_14" y="33.75" x="50.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">FULL</text> + <text xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="8" id="svg_15" y="44.75" x="47.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">ADDER</text> + </g> +</svg>
\ No newline at end of file diff --git a/views/webtronix_server/subcircuits/fulladdersubcircuit.png b/views/webtronix_server/subcircuits/fulladdersubcircuit.png Binary files differnew file mode 100644 index 0000000..c9b7d0d --- /dev/null +++ b/views/webtronix_server/subcircuits/fulladdersubcircuit.png diff --git a/views/webtronix_server/subcircuits/halfadder.svg b/views/webtronix_server/subcircuits/halfadder.svg new file mode 100644 index 0000000..4525fe9 --- /dev/null +++ b/views/webtronix_server/subcircuits/halfadder.svg @@ -0,0 +1,42 @@ +<svg width="104" height="74" xmlns="http://www.w3.org/2000/svg"> + <!-- Created with Method Draw - http://github.com/duopixel/Method-Draw/ --> + <g id="x" + class="halfadder"> + +<metadata class="part" > + <wtx:part xmlns:wtx="http://code.google.com/p/webtronics" > + <wtx:pins> + <wtx:analog> + <wtx:node index="1" x="0" y="19"/> + <wtx:node index="2" x="0" y="59"/> + <wtx:node index="3" x="103" y="19"/> + <wtx:node index="4" x="103" y="59"/> + </wtx:analog> + </wtx:pins> + <wtx:id>x</wtx:id> + + <wtx:type>x</wtx:type> + <wtx:name>halfadder</wtx:name> + <wtx:category>subcircuits</wtx:category> + <wtx:flip></wtx:flip> + <wtx:value></wtx:value> + <wtx:label></wtx:label> + <wtx:spice></wtx:spice> + <wtx:model></wtx:model> + </wtx:part> +</metadata> + + + <rect id="svg_1" height="70" width="55" y="2.75" x="23.75" stroke-width="1.5" stroke="#000" fill="#fff"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_4" y2="18.75" x2="102.75" y1="18.75" x1="79.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_5" y2="19.75" x2="23.75" y1="19.75" x1="0.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_6" y2="57.75" x2="102.75" y1="57.75" x1="79.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <line stroke-linecap="null" stroke-linejoin="null" id="svg_8" y2="58.75" x2="23.75" y1="58.75" x1="0.75" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#000" fill="none"/> + <text style="cursor: move;" xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_9" y="24.75" x="26.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">IN1</text> + <text xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_10" y="62.75" x="26.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">IN2</text> + <text xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_12" y="23.75" x="55.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">SUM</text> + <text style="cursor: move;" xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="9" id="svg_13" y="62.75" x="51.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">COUT</text> + <text style="cursor: move;" xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="8" id="svg_14" y="33.75" x="50.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">HALF</text> + <text xml:space="preserve" text-anchor="start" font-family="Helvetica, Arial, sans-serif" font-size="8" id="svg_15" y="44.75" x="47.75" fill-opacity="null" stroke-opacity="null" stroke-width="0" stroke="#000" fill="#000000">ADDER</text> + </g> +</svg>
\ No newline at end of file diff --git a/views/webtronix_server/subcircuits/halfaddersubcircuit.png b/views/webtronix_server/subcircuits/halfaddersubcircuit.png Binary files differnew file mode 100644 index 0000000..ce6d477 --- /dev/null +++ b/views/webtronix_server/subcircuits/halfaddersubcircuit.png diff --git a/views/webtronix_server/subcircuits/opampsubcircuit.png b/views/webtronix_server/subcircuits/opampsubcircuit.png Binary files differnew file mode 100644 index 0000000..49c322d --- /dev/null +++ b/views/webtronix_server/subcircuits/opampsubcircuit.png diff --git a/views/webtronix_server/diodes/scr.svg b/views/webtronix_server/subcircuits/scr.svg index 95048a6..570ddd6 100644 --- a/views/webtronix_server/diodes/scr.svg +++ b/views/webtronix_server/subcircuits/scr.svg @@ -9,10 +9,10 @@ <g connects="0,10;40,10;0,20" stroke='black' stroke-width='2px' - id="D" - classs="scr" > + id="x" + class="scr" > <metadata class="part" > - <wtx:part xmlns:wtx="/home/niel/Desktop/webtronics" > + <wtx:part xmlns:wtx="http://code.google.com/p/webtronics" > <wtx:pins> <wtx:analog> <wtx:node index="1" x="0" y="10"/> @@ -20,11 +20,11 @@ <wtx:node index="3" x="0" y="20"/> </wtx:analog> </wtx:pins> - <wtx:id>d</wtx:id> + <wtx:id>x</wtx:id> - <wtx:type>d</wtx:type> + <wtx:type>x</wtx:type> <wtx:name>scr</wtx:name> - <wtx:category>diodes</wtx:category> + <wtx:category>subcircuits</wtx:category> <wtx:flip></wtx:flip> <wtx:value></wtx:value> <wtx:label></wtx:label> diff --git a/views/webtronix_server/subcircuits/scrsubcircuit.png b/views/webtronix_server/subcircuits/scrsubcircuit.png Binary files differnew file mode 100644 index 0000000..ee4e768 --- /dev/null +++ b/views/webtronix_server/subcircuits/scrsubcircuit.png diff --git a/views/webtronix_server/diodes/triac.svg b/views/webtronix_server/subcircuits/triac.svg index 096cd2f..168a93f 100644 --- a/views/webtronix_server/diodes/triac.svg +++ b/views/webtronix_server/subcircuits/triac.svg @@ -8,7 +8,7 @@ > <g stroke='black' stroke-width='2px' - id="D" + id="x" class ="triac"> <metadata class="part" > <wtx:part xmlns:wtx="/home/niel/Desktop/webtronics" > @@ -19,11 +19,11 @@ <wtx:node index="3" x="40" y="20"/> </wtx:analog> </wtx:pins> - <wtx:id>d</wtx:id> + <wtx:id>x</wtx:id> - <wtx:type>d</wtx:type> + <wtx:type>x</wtx:type> <wtx:name>triac</wtx:name> - <wtx:category>diodes</wtx:category> + <wtx:category>subcircuits</wtx:category> <wtx:flip></wtx:flip> <wtx:value></wtx:value> <wtx:label></wtx:label> diff --git a/views/webtronix_server/subcircuits/triacsubcircuit.png b/views/webtronix_server/subcircuits/triacsubcircuit.png Binary files differnew file mode 100644 index 0000000..295ab8f --- /dev/null +++ b/views/webtronix_server/subcircuits/triacsubcircuit.png |