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;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'); 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-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