From 580e62658e53c4059626de70377954862fc84a00 Mon Sep 17 00:00:00 2001 From: Abhishek Patel Date: Fri, 27 May 2016 17:45:35 +0530 Subject: Added analysis before generating netlist --- views/schematic.html | 132 +++++++++++++++++++------- views/script/gui.js | 190 ++++++++++++++++++++++++++++++++++++-- views/script/netlist.js | 20 ++-- views/script/savenetlist.js | 149 ++++++++++++------------------ views/script/schematic.js | 5 + views/webtronix_server/parts.json | 1 + 6 files changed, 361 insertions(+), 136 deletions(-) (limited to 'views') diff --git a/views/schematic.html b/views/schematic.html index 2f587f1..4d8ef86 100644 --- a/views/schematic.html +++ b/views/schematic.html @@ -28,6 +28,7 @@ toolbar
Circuit + @@ -209,39 +210,39 @@ add code text - - - + + + + + + + + + + + + + + + + + + diff --git a/views/script/gui.js b/views/script/gui.js index 7a3a2ec..e7325ae 100644 --- a/views/script/gui.js +++ b/views/script/gui.js @@ -1,3 +1,10 @@ + + + + +globalVariable=0; + + var webtronics={ circuit:null, copy:null, @@ -142,8 +149,13 @@ var webtronics={ var id=netlistcreator.readwtx(this.circuit.selected[0],"id"); var value=netlistcreator.readwtx(this.circuit.selected[0],"value"); + + if(id!=""){$('webtronics_part_id').value=id;} if(value!=""){$('webtronics_part_value').value=value;} + + + $("webtronics_part_dir_value").value=netlistcreator.readwtx(this.circuit.selected[0],'model'); if(!netlistcreator.readwtx(webtronics.circuit.selected[0],"value")){ @@ -636,15 +648,31 @@ console.log(exception); }); /* if($('webtronics_save')){ - Event.observe($('webtronics_save'), 'click', function() { + 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 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"; + } +console.log(Flag+"2\n"); + +} + +else if( change_val == "1") + +{ + console.log(Flag+"as\n"); + 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"; + } + console.log(Flag+"as\n"); + +} + + + + + + + + } + 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()); @@ -719,7 +887,9 @@ console.log(exception); netlistcreator.writewtx(model,"model",$('webtronics_part_dir_value').value); netlistcreator.writewtx(model,"measure",$('webtronics_print_dir_value').value); - webtronics.circuit.createvalue(webtronics.circuit.selected[0]); + + + webtronics.circuit.createvalue(webtronics.circuit.selected[0]); }); if($('webtronics_properties_cancel'))Event.observe($('webtronics_properties_cancel'), 'click', function() { @@ -837,7 +1007,13 @@ console.log(exception); $('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); diff --git a/views/script/netlist.js b/views/script/netlist.js index cb32f7a..0fe044c 100644 --- a/views/script/netlist.js +++ b/views/script/netlist.js @@ -129,7 +129,7 @@ sortnetlist:function(list){ 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)}); + 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)}); @@ -203,6 +203,7 @@ getwtxdata:function(parts){ 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"); @@ -244,7 +245,7 @@ getwtxdata:function(parts){ } catch(e){part.error="wtx:category not found";} try{ - part.value=this.readwtx(parts[i],'value'); + part.value=this.readwtx(parts[i],'value'); } catch(e){part.error="wtx:value not found";} try{ @@ -260,7 +261,7 @@ getwtxdata:function(parts){ part.measure=this.readwtx(parts[i],'measure'); } catch(e){} - + list.push(part); } return list; @@ -429,18 +430,24 @@ getnodes:function(parts){ createnetlist:function(responsefunc){ var parts=webtronics.circuit.getwithselector('#webtronics_drawing > g'); + if(parts.length<1){ - responsefunc("no parts found (moded by Niel Mishra)\n"); + 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 by Niel Mishra* \n"; + var spice="*ngspice netlist * \n"; var sections=this.getnodes(partswtx); //dump models into spice @@ -458,9 +465,10 @@ createnetlist:function(responsefunc){ for(var j=0;j b.index? 1:a.index < b.index?-1:0;}) // console.log(pins); - for(var j=0;j 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"; - } - -} + + + +/*------------------------------------------------------------------------------------------------------------------------------------------------ +Netlist Generation +----------------------*/ + }); -}); + + diff --git a/views/script/schematic.js b/views/script/schematic.js index a6175d1..ab611ee 100644 --- a/views/script/schematic.js +++ b/views/script/schematic.js @@ -678,6 +678,7 @@ Schematic.prototype.createvalue=function(elem){ var id=this.readwtx(elem,"id"); var value=this.readwtx(elem,"value"); var label=this.readwtx(elem,"label"); + } catch(e){console.log(e);} if(label.length && $(label)){ @@ -689,6 +690,8 @@ Schematic.prototype.createvalue=function(elem){ var idspan=this.createtspan(id,0,0); $(label).appendChild(idspan); } + + if(value){ var box=this.tracker($(label)); var valuespan=this.createtspan(value,-box.width,box.height); @@ -696,6 +699,7 @@ Schematic.prototype.createvalue=function(elem){ } $(label).appendChild(idspan); $(label).appendChild(valuespan); + $(label).appendChild(tempspan); } else{ var text=this.createtext("",'black',0,0-this.fontsize); @@ -706,6 +710,7 @@ Schematic.prototype.createvalue=function(elem){ var idspan=this.createtspan(id,0,0); text.appendChild(idspan); } + if(value){ var box=this.tracker(text); var valuespan=this.createtspan(value,-box.width,box.height); diff --git a/views/webtronix_server/parts.json b/views/webtronix_server/parts.json index 49052f0..8ae516d 100644 --- a/views/webtronix_server/parts.json +++ b/views/webtronix_server/parts.json @@ -186,6 +186,7 @@ "transformer":{} }, "power":{ + "current":{ "values":{ -- cgit