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 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;ibpart); }; 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 * * * * * * r * r * testresistor * resistors * * * * * */ getwtxdata:function(parts){ list=[]; for(var i=0;i 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 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'); } 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";} //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-1){ return true; } } return false; }, /* test if wires are connected anywhere*/ getconnected:function(wirelist,wire){ for(var i=0;i line, #information > .webtronics_namewire_connector'); for(var i =0 ;i 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 b.index? 1:a.index < b.index?-1:0;}) // console.log(pins); for(var j=0;j .webtronics_namewire_connector') for(var i=0;i