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 X=[]; 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); X.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)}); X.each(function(item){newlist.push(item)}); A.each(function(item){ newlist.push(item); console.log("Item--->"+Object.keys(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;}); part.pin=this.readwtx(parts[i],'digitalpins'); console.log("Parts ID: "+part.pin); } 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.pwlval=this.readwtx(parts[i],'pwlval'); } catch(e){part.error="wtx:PWL 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{ console.log("RiseDelay Parts :"+parts[i]) part.risedelay=this.readwtx(parts[i],'risedelay'); console.log("part.risedelay :"+part.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){part.error="wtx:measure not found";} try{ part.inoffset=this.readwtx(parts[i],'inoffset'); } catch(e){ part.error="wtx:inoffset not found"; } try{ part.gain=this.readwtx(parts[i],'gain'); } catch(e){ part.error="wtx:gain not found"; } try{ part.outoffset=this.readwtx(parts[i],'outoffset'); } catch(e){ part.error="wtx:outoffset not found"; } try{ part.ingain=this.readwtx(parts[i],'ingain'); } catch(e){ part.error="wtx:ingain not found"; } try{ part.outgain=this.readwtx(parts[i],'outgain'); } catch(e){ part.error="wtx:outgain not found"; } try{ part.denoffset=this.readwtx(parts[i],'denoffset'); } catch(e){ part.error="wtx:denoffset not found"; } try{ part.dengain=this.readwtx(parts[i],'dengain'); } catch(e){ part.error="wtx:dengain not found"; } try{ part.numoffset=this.readwtx(parts[i],'numoffset'); } catch(e){ part.error="wtx:numoffset not found"; } try{ part.numgain=this.readwtx(parts[i],'numgain'); } catch(e){ part.error="wtx:numgain not found"; } try{ part.fraction=this.readwtx(parts[i],'fraction'); } catch(e){ part.error="wtx:fraction not found"; } try{ part.dendomain=this.readwtx(parts[i],'dendomain'); } catch(e){ part.error="wtx:dendomain not found"; } try{ part.denlowerlimit=this.readwtx(parts[i],'denlowerlimit'); } catch(e){ part.error="wtx:denlowerlimit not found"; } try{ part.outlowerlimit=this.readwtx(parts[i],'outlowerlimit'); } catch(e){ part.error="wtx:outlowerlimit not found"; } try{ part.outupperlimit=this.readwtx(parts[i],'outupperlimit'); } catch(e){ part.error="wtx:outupperlimit not found"; } try{ part.limitrange=this.readwtx(parts[i],'limitrange'); } catch(e){ part.error="wtx:limitrange not found"; } try{ part.upperdelta=this.readwtx(parts[i],'upperdelta'); } catch(e){ part.error="wtx:upperdelta not found"; } try{ part.lowerdelta=this.readwtx(parts[i],'lowerdelta'); } catch(e){ part.error="wtx:lowerdelta not found"; } try{ part.indomain=this.readwtx(parts[i],'indomain'); } catch(e){ part.error="wtx:indomain not found"; } try{ part.xarr=this.readwtx(parts[i],'xarr'); } catch(e){ part.error="wtx:xarr not found"; } try{ part.yarr=this.readwtx(parts[i],'yarr'); } catch(e){ part.error="wtx:yarr not found"; } try{ part.amodel=this.readwtx(parts[i],'amodel'); } catch(e){ part.error="wtx:amodel not found"; } try{ part.coff=this.readwtx(parts[i],'coff'); } catch(e){ part.error="wtx:coff not found"; } try{ part.con=this.readwtx(parts[i],'con'); } catch(e){ part.error="wtx:con not found"; } try{ part.roff=this.readwtx(parts[i],'roff'); } catch(e){ part.error="wtx:roff not found"; } try{ part.irev=this.readwtx(parts[i],'irev'); } catch(e){ part.error="wtx:irev not found"; } try{ part.rbreak=this.readwtx(parts[i],'rbreak'); } catch(e){ part.error="wtx:rbreak not found"; } try{ part.limitswitch=this.readwtx(parts[i],'limitswitch'); } catch(e){ part.error="wtx:limitswitch not found"; } try{ part.ron=this.readwtx(parts[i],'ron'); } catch(e){ part.error="wtx:ron not found"; } try{ part.log=this.readwtx(parts[i],'log'); } catch(e){ part.error="wtx:log not found"; } try{ part.vbreak=this.readwtx(parts[i],'vbreak'); } catch(e){ part.error="wtx:vbreak not found"; } try{ part.ibreak=this.readwtx(parts[i],'ibreak'); } catch(e){ part.error="wtx:ibreak not found"; } try{ part.isat=this.readwtx(parts[i],'isat'); } catch(e){ part.error="wtx:isat not found"; } try{ part.nfor=this.readwtx(parts[i],'nfor'); } catch(e){ part.error="wtx:nfor not found"; } try{ part.rsource=this.readwtx(parts[i],'rsource'); } catch(e){ part.error="wtx:rsource not found"; } try{ part.rsink=this.readwtx(parts[i],'rsink'); } catch(e){ part.error="wtx:rsink not found"; } try{ part.ilimitsink=this.readwtx(parts[i],'ilimitsink'); } catch(e){ part.error="wtx:ilimitsink not found"; } try{ part.ilimitsource=this.readwtx(parts[i],'ilimitsource'); } catch(e){ part.error="wtx:ilimitsource not found"; } try{ part.vpwr=this.readwtx(parts[i],'vpwr'); } catch(e){ part.error="wtx:vpwr not found"; } try{ part.isource=this.readwtx(parts[i],'isource'); } catch(e){ part.error="wtx:isource not found"; } try{ part.isink=this.readwtx(parts[i],'isink'); } catch(e){ part.error="wtx:isink not found"; } try{ part.routdomain=this.readwtx(parts[i],'routdomain'); } catch(e){ part.error="wtx:routdomain not found"; } try{ part.inlow=this.readwtx(parts[i],'inlow'); } catch(e){ part.error="wtx:inlow not found"; } try{ part.inhigh=this.readwtx(parts[i],'inhigh'); } catch(e){ part.error="wtx:inhigh not found"; } try{ part.hyst=this.readwtx(parts[i],'hyst'); } catch(e){ part.error="wtx:hyst not found"; } try{ part.outic=this.readwtx(parts[i],'outic'); } catch(e){ part.error="wtx:outic not found"; } try{ part.numcoeff=this.readwtx(parts[i],'numcoeff'); } catch(e){ part.error="wtx:numcoeff not found"; } try{ part.dencoeff=this.readwtx(parts[i],'dencoeff'); } catch(e){ part.error="wtx:dencoeff not found"; } try{ part.lowerdelta=this.readwtx(parts[i],'lowerdelta'); } catch(e){ part.error="wtx:lowerdelta not found"; } try{ part.intic=this.readwtx(parts[i],'intic'); } catch(e){ part.error="wtx:intic not found"; } try{ part.denormfreq=this.readwtx(parts[i],'denormfreq'); } catch(e){ part.error="wtx:denormfreq not found"; } try{ part.riseslope=this.readwtx(parts[i],'riseslope'); } catch(e){ part.error="wtx:riseslope not found"; } try{ part.fallslope=this.readwtx(parts[i],'fallslope'); } catch(e){ part.error="wtx:fallslope not found"; } try{ part.outlow=this.readwtx(parts[i],'outlow'); } catch(e){ part.error="wtx:outlow not found"; } try{ part.outhigh=this.readwtx(parts[i],'outhigh'); } catch(e){ part.error="wtx:outhigh not found"; } try{ part.cntlarr=this.readwtx(parts[i],'cntlarr'); } catch(e){ part.error="wtx:cntlarr not found"; } try{ part.freqarr=this.readwtx(parts[i],'freqarr'); } catch(e){ part.error="wtx:freqarr not found"; } try{ part.duty=this.readwtx(parts[i],'duty'); } catch(e){ part.error="wtx:duty not found"; } try{ part.risetime=this.readwtx(parts[i],'risetime'); } catch(e){ part.error="wtx:risetime not found"; } try{ part.falltime=this.readwtx(parts[i],'falltime'); } catch(e){ part.error="wtx:falltime not found"; } try{ part.clktrig=this.readwtx(parts[i],'clktrig'); } catch(e){ part.error="wtx:clktrig not found"; } try{ part.pwarr=this.readwtx(parts[i],'pwarr'); } catch(e){ part.error="wtx:pwarr not found"; } try{ part.ptrig=this.readwtx(parts[i],'ptrig'); } catch(e){ part.error="wtx:ptrig not found"; } try{ part.rdelay=this.readwtx(parts[i],'rdelay'); } catch(e){ part.error="wtx:rdelay not found"; } try{ part.fdelay=this.readwtx(parts[i],'fdelay'); } catch(e){ part.error="wtx:fdelay not found"; } try{ part.rmax=this.readwtx(parts[i],'rmax'); } catch(e){ part.error="wtx:rmax not found"; } try{ part.rmin=this.readwtx(parts[i],'rmin'); } catch(e){ part.error="wtx:rmin not found"; } try{ part.rinit=this.readwtx(parts[i],'isource'); } catch(e){ part.error="wtx:isource not found"; } try{ part.vt=this.readwtx(parts[i],'vt'); } catch(e){ part.error="wtx:vt not found"; } try{ part.alpha=this.readwtx(parts[i],'alpha'); } catch(e){ part.error="wtx:alpha not found"; } try{ part.beta=this.readwtx(parts[i],'beta'); } catch(e){ part.error="wtx:beta not found"; } try{ part.clkdelay=this.readwtx(parts[i],'clkdelay'); } catch(e){ part.error="wtx:clkdelay not found"; } try{ part.setdelay=this.readwtx(parts[i],'setdelay'); } catch(e){ part.error="wtx:setdelay not found"; } try{ part.resetdelay=this.readwtx(parts[i],'resetdelay'); } catch(e){ part.error="wtx:resetdelay not found"; } try{ part.ic=this.readwtx(parts[i],'ic'); } catch(e){ part.error="wtx:ic not found"; } try{ part.dataload=this.readwtx(parts[i],'dataload'); } catch(e){ part.error="wtx:dataload not found"; } try{ part.jkload=this.readwtx(parts[i],'jkload'); } catch(e){ part.error="wtx:jkload not found"; } try{ part.tload=this.readwtx(parts[i],'tload'); } catch(e){ part.error="wtx:tload not found"; } try{ part.srload=this.readwtx(parts[i],'srload'); } catch(e){ part.error="wtx:srload not found"; } try{ part.clkload=this.readwtx(parts[i],'clkload'); } catch(e){ part.error="wtx:clkload not found"; } try{ part.setload=this.readwtx(parts[i],'setload'); } catch(e){ part.error="wtx:setload not found"; } try{ part.resetload=this.readwtx(parts[i],'resetload'); } catch(e){ part.error="wtx:resetload not found"; } try{ part.enableload=this.readwtx(parts[i],'enableload'); } catch(e){ part.error="wtx:enableload not found"; } try{ part.datadelay=this.readwtx(parts[i],'datadelay'); } catch(e){ part.error="wtx:datadelay not found"; } try{ part.enabledelay=this.readwtx(parts[i],'enabledelay'); } catch(e){ part.error="wtx:enabledelay not found"; } try{ part.srdelay=this.readwtx(parts[i],'srdelay'); } catch(e){ part.error="wtx:srdelay load not found"; } try{ part.srdelay=this.readwtx(parts[i],'srdelay'); } catch(e){ part.error="wtx:srdelay load not found"; } try{ part.outdef=this.readwtx(parts[i],'outdef'); } catch(e){ part.error="wtx:outdef load not found"; } try{ part.outundef=this.readwtx(parts[i],'outundef');} catch(e){ part.error="wtx:outdef load not found";} 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"+Object.keys(wire)); } 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 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"+command); command+=" adc_"+pid+"\n.model adc_"+pid+" adc_bridge(in_low ="+il+" in_high = "+ih+" rise_delay = "+rised+" fall_delay = "+falld+")\n"; } else if(sections.netlist[i].name=="cdo") { var ca=sections.netlist[i].cntlarr; var fa=sections.netlist[i].freqarr; var dt=sections.netlist[i].duty; var p=sections.netlist[i].phase; var rised=sections.netlist[i].risedelay; var falld=sections.netlist[i].falldelay; command+=" var_clock"+pid+"\n.model var_clock"+pid+" d_osc(cntl_array = [ "+ca+"] freq_array = [ "+fa+" ] duty_cycle = "+dt+" initphase = "+p+" rise_delay = "+rised+" fall_delay = "+falld+")\n"; } else{ command+=" "+sections.netlist[i].model; } if(command!="")spice+=command+'\n'; } } if(sections.coupling.length){ for(var i=0;i .webtronics_namewire_connector') for(var i=0;i