Commit 15cbd194 by jmclaus

Merge pull request #4745 from stvstnfrd/circuit/clean

Remove JavaScript variables from global namespace
parents d77fe6e5 1aeadcda
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
// for modified nodal analysis (MNA) stamps see // for modified nodal analysis (MNA) stamps see
// http://www.analog-electronics.eu/analog-electronics/modified-nodal-analysis/modified-nodal-analysis.xhtml // http://www.analog-electronics.eu/analog-electronics/modified-nodal-analysis/modified-nodal-analysis.xhtml
cktsim = (function() { var cktsim = (function() {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Circuit // Circuit
...@@ -21,37 +20,34 @@ cktsim = (function() { ...@@ -21,37 +20,34 @@ cktsim = (function() {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// types of "nodes" in the linear system // types of "nodes" in the linear system
T_VOLTAGE = 0; var T_VOLTAGE = 0;
T_CURRENT = 1; var T_CURRENT = 1;
v_newt_lim = 0.3; // Voltage limited Newton great for Mos/diodes var v_newt_lim = 0.3; // Voltage limited Newton great for Mos/diodes
v_abstol = 1e-6; // Absolute voltage error tolerance var v_abstol = 1e-6; // Absolute voltage error tolerance
i_abstol = 1e-12; // Absolute current error tolerance var i_abstol = 1e-12; // Absolute current error tolerance
eps = 1.0e-12; // A very small number compared to one. var eps = 1.0e-12; // A very small number compared to one.
dc_max_iters = 1000; // max iterations before giving pu var dc_max_iters = 1000; // max iterations before giving up
max_tran_iters = 20; // max iterations before giving up var max_tran_iters = 20; // max iterations before giving up
time_step_increase_factor = 2.0; // How much can lte let timestep grow. var time_step_increase_factor = 2.0; // How much can lte let timestep grow.
lte_step_decrease_factor = 8; // Limit lte one-iter timestep shrink. var lte_step_decrease_factor = 8; // Limit lte one-iter timestep shrink.
nr_step_decrease_factor = 4; // Newton failure timestep shink. var nr_step_decrease_factor = 4; // Newton failure timestep shrink.
reltol = 0.0001; // Relative tol to max observed value var reltol = 0.0001; // Relative tol to max observed value
lterel = 10; // LTE/Newton tolerance ratio (> 10!) var lterel = 10; // LTE/Newton tolerance ratio (> 10!)
res_check_abs = Math.sqrt(i_abstol); // Loose Newton residue check var res_check_abs = Math.sqrt(i_abstol); // Loose Newton residue check
res_check_rel = Math.sqrt(reltol); // Loose Newton residue check var res_check_rel = Math.sqrt(reltol); // Loose Newton residue check
function Circuit() { function Circuit() {
this.node_map = new Array(); this.node_map = [];
this.ntypes = []; this.ntypes = [];
this.initial_conditions = []; // ic's for each element this.initial_conditions = [];
this.devices = [];
this.devices = []; // list of devices this.device_map = [];
this.device_map = new Array(); // map name -> device this.voltage_sources = [];
this.voltage_sources = []; // list of voltage sources this.current_sources = [];
this.current_sources = []; // list of current sources
this.finalized = false; this.finalized = false;
this.diddc = false; this.diddc = false;
this.node_index = -1; this.node_index = -1;
this.periods = 1 this.periods = 1
} }
...@@ -102,7 +98,7 @@ cktsim = (function() { ...@@ -102,7 +98,7 @@ cktsim = (function() {
} }
// Check for voltage source loops. // Check for voltage source loops.
n_vsrc = this.voltage_sources.length; var n_vsrc = this.voltage_sources.length;
if (n_vsrc > 0) { // At least one voltage source if (n_vsrc > 0) { // At least one voltage source
var GV = mat_make(n_vsrc, this.N); // Loop check var GV = mat_make(n_vsrc, this.N); // Loop check
for (var i = n_vsrc - 1; i >= 0; --i) { for (var i = n_vsrc - 1; i >= 0; --i) {
...@@ -187,7 +183,6 @@ cktsim = (function() { ...@@ -187,7 +183,6 @@ cktsim = (function() {
return false; return false;
} }
return true; return true;
} }
// if converges: updates this.solution, this.soln_max, returns iter count // if converges: updates this.solution, this.soln_max, returns iter count
...@@ -196,11 +191,12 @@ cktsim = (function() { ...@@ -196,11 +191,12 @@ cktsim = (function() {
Circuit.prototype.find_solution = function(load,maxiters) { Circuit.prototype.find_solution = function(load,maxiters) {
var soln = this.solution; var soln = this.solution;
var rhs = this.rhs; var rhs = this.rhs;
var d_sol = new Array(); var d_sol = [];
var abssum_compare; var abssum_compare;
var converged,abssum_old=0, abssum_rhs; var converged,abssum_old=0, abssum_rhs;
var use_limiting = false; var use_limiting = false;
var down_count = 0; var down_count = 0;
var thresh;
// iteratively solve until values convere or iteration limit exceeded // iteratively solve until values convere or iteration limit exceeded
for (var iter = 0; iter < maxiters; iter++) { for (var iter = 0; iter < maxiters; iter++) {
...@@ -221,7 +217,6 @@ cktsim = (function() { ...@@ -221,7 +217,6 @@ cktsim = (function() {
use_limiting = true; use_limiting = true;
} }
else { // Compute the Newton delta else { // Compute the Newton delta
//d_sol = mat_solve(this.matrix,rhs);
d_sol = mat_solve_rq(this.matrix,rhs); d_sol = mat_solve_rq(this.matrix,rhs);
// If norm going down for ten iters, stop limiting // If norm going down for ten iters, stop limiting
...@@ -267,12 +262,10 @@ cktsim = (function() { ...@@ -267,12 +262,10 @@ cktsim = (function() {
} }
} }
//alert(numeric.prettyPrint(this.solution);)
if (converged == true) { if (converged == true) {
for (var i = this.N - 1; i >= 0; --i) for (var i = this.N - 1; i >= 0; --i)
if (Math.abs(soln[i]) > this.soln_max[i]) if (Math.abs(soln[i]) > this.soln_max[i])
this.soln_max[i] = Math.abs(soln[i]); this.soln_max[i] = Math.abs(soln[i]);
return iter+1; return iter+1;
} }
} }
...@@ -281,7 +274,6 @@ cktsim = (function() { ...@@ -281,7 +274,6 @@ cktsim = (function() {
// DC analysis // DC analysis
Circuit.prototype.dc = function() { Circuit.prototype.dc = function() {
// Allocation matrices for linear part, etc. // Allocation matrices for linear part, etc.
if (this.finalize() == false) if (this.finalize() == false)
return undefined; return undefined;
...@@ -315,7 +307,7 @@ cktsim = (function() { ...@@ -315,7 +307,7 @@ cktsim = (function() {
// Note that a dc solution was computed // Note that a dc solution was computed
this.diddc = true; this.diddc = true;
// create solution dictionary // create solution dictionary
var result = new Array(); var result = [];
// capture node voltages // capture node voltages
for (var name in this.node_map) { for (var name in this.node_map) {
var index = this.node_map[name]; var index = this.node_map[name];
...@@ -348,7 +340,6 @@ cktsim = (function() { ...@@ -348,7 +340,6 @@ cktsim = (function() {
for (var i = ckt.N-1; i >= 0; --i) { for (var i = ckt.N-1; i >= 0; --i) {
var dqdt = ckt.alpha0*ckt.q[i] + ckt.alpha1*ckt.oldq[i] + var dqdt = ckt.alpha0*ckt.q[i] + ckt.alpha1*ckt.oldq[i] +
ckt.alpha2*ckt.old2q[i]; ckt.alpha2*ckt.old2q[i];
//alert(numeric.prettyPrint(dqdt));
rhs[i] = ckt.beta0[i]*ckt.c[i] + ckt.beta1[i]*ckt.oldc[i] - dqdt; rhs[i] = ckt.beta0[i]*ckt.c[i] + ckt.beta1[i]*ckt.oldc[i] - dqdt;
} }
// matrix = beta0*G + alpha0*C. // matrix = beta0*G + alpha0*C.
...@@ -424,7 +415,7 @@ cktsim = (function() { ...@@ -424,7 +415,7 @@ cktsim = (function() {
// build array to hold list of results for each variable // build array to hold list of results for each variable
// last entry is for timepoints. // last entry is for timepoints.
var response = new Array(N + 1); var response = new Array(N + 1);
for (var i = N; i >= 0; --i) response[i] = new Array(); for (var i = N; i >= 0; --i) response[i] = [];
// Allocate back vectors for up to a second order method // Allocate back vectors for up to a second order method
this.old3sol = new Array(this.N); this.old3sol = new Array(this.N);
...@@ -473,8 +464,6 @@ cktsim = (function() { ...@@ -473,8 +464,6 @@ cktsim = (function() {
period = Math.min(period, per); period = Math.min(period, per);
} }
this.periods = Math.ceil((tstop - tstart)/period); this.periods = Math.ceil((tstop - tstart)/period);
//alert('number of periods ' + this.periods);
this.time = tstart; this.time = tstart;
// ntpts adjusted by numbers of periods in input // ntpts adjusted by numbers of periods in input
...@@ -495,7 +484,6 @@ cktsim = (function() { ...@@ -495,7 +484,6 @@ cktsim = (function() {
this.oldc[i] = this.c[i]; this.oldc[i] = this.c[i];
} }
var beta0,beta1; var beta0,beta1;
// Start with two pseudo-Euler steps, maximum 50000 steps/period // Start with two pseudo-Euler steps, maximum 50000 steps/period
var max_nsteps = this.periods*50000; var max_nsteps = this.periods*50000;
...@@ -511,7 +499,6 @@ cktsim = (function() { ...@@ -511,7 +499,6 @@ cktsim = (function() {
this.old3q[i] = this.oldq[i]; this.old3q[i] = this.oldq[i];
this.old2q[i] = this.oldq[i]; this.old2q[i] = this.oldq[i];
this.oldq[i] = this.q[i]; this.oldq[i] = this.q[i];
} }
if (step_index < 0) { // Take a prestep using BE if (step_index < 0) { // Take a prestep using BE
...@@ -572,7 +559,6 @@ cktsim = (function() { ...@@ -572,7 +559,6 @@ cktsim = (function() {
if (step_index > 0) new_step = time_step_increase_factor*this.min_step; if (step_index > 0) new_step = time_step_increase_factor*this.min_step;
break; break;
} else if (iterations == undefined) { // NR nonconvergence, shrink by factor } else if (iterations == undefined) { // NR nonconvergence, shrink by factor
//alert('timestep nonconvergence ' + this.time + ' ' + step_index);
this.time = this.oldt + this.time = this.oldt +
(this.time - this.oldt)/nr_step_decrease_factor; (this.time - this.oldt)/nr_step_decrease_factor;
} else { // Check the LTE and shrink step if needed. } else { // Check the LTE and shrink step if needed.
...@@ -587,7 +573,7 @@ cktsim = (function() { ...@@ -587,7 +573,7 @@ cktsim = (function() {
} }
// create solution dictionary // create solution dictionary
var result = new Array(); var result = [];
for (var name in this.node_map) { for (var name in this.node_map) {
var index = this.node_map[name]; var index = this.node_map[name];
result[name] = (index == -1) ? 0 : response[index]; result[name] = (index == -1) ? 0 : response[index];
...@@ -629,7 +615,7 @@ cktsim = (function() { ...@@ -629,7 +615,7 @@ cktsim = (function() {
// build array to hold list of magnitude and phases for each node // build array to hold list of magnitude and phases for each node
// last entry is for frequency values // last entry is for frequency values
var response = new Array(2*N + 1); var response = new Array(2*N + 1);
for (var i = 2*N; i >= 0; --i) response[i] = new Array(); for (var i = 2*N; i >= 0; --i) response[i] = [];
// multiplicative frequency increase between freq points // multiplicative frequency increase between freq points
var delta_f = Math.exp(Math.LN10/npts); var delta_f = Math.exp(Math.LN10/npts);
...@@ -685,7 +671,7 @@ cktsim = (function() { ...@@ -685,7 +671,7 @@ cktsim = (function() {
} }
// create solution dictionary // create solution dictionary
var result = new Array(); var result = [];
for (var name in this.node_map) { for (var name in this.node_map) {
var index = this.node_map[name]; var index = this.node_map[name];
result[name] = (index == -1) ? 0 : response[index]; result[name] = (index == -1) ? 0 : response[index];
...@@ -695,7 +681,6 @@ cktsim = (function() { ...@@ -695,7 +681,6 @@ cktsim = (function() {
return result; return result;
} }
// Helper for adding devices to a circuit, warns on duplicate device names. // Helper for adding devices to a circuit, warns on duplicate device names.
Circuit.prototype.add_device = function(d,name) { Circuit.prototype.add_device = function(d,name) {
// Add device to list of devices and to device map // Add device to list of devices and to device map
...@@ -738,7 +723,6 @@ cktsim = (function() { ...@@ -738,7 +723,6 @@ cktsim = (function() {
} // zero area diodes discarded. } // zero area diodes discarded.
} }
Circuit.prototype.c = function(n1,n2,v,name) { Circuit.prototype.c = function(n1,n2,v,name) {
// try to convert string value into numeric value, barf if we can't // try to convert string value into numeric value, barf if we can't
if ((typeof v) == 'string') { if ((typeof v) == 'string') {
...@@ -774,6 +758,7 @@ cktsim = (function() { ...@@ -774,6 +758,7 @@ cktsim = (function() {
} }
Circuit.prototype.opamp = function(np,nn,no,ng,A,name) { Circuit.prototype.opamp = function(np,nn,no,ng,A,name) {
var ratio;
// try to convert string value into numeric value, barf if we can't // try to convert string value into numeric value, barf if we can't
if ((typeof A) == 'string') { if ((typeof A) == 'string') {
ratio = parse_number(A,undefined); ratio = parse_number(A,undefined);
...@@ -939,7 +924,7 @@ cktsim = (function() { ...@@ -939,7 +924,7 @@ cktsim = (function() {
// variables (rows that can be removed without changing rank(M). // variables (rows that can be removed without changing rank(M).
Circuit.prototype.algebraic = function(M) { Circuit.prototype.algebraic = function(M) {
var Nr = M.length var Nr = M.length
Mc = mat_make(Nr, Nr); var Mc = mat_make(Nr, Nr);
mat_copy(M,Mc); mat_copy(M,Mc);
var R = mat_rank(Mc); var R = mat_rank(Mc);
...@@ -969,7 +954,6 @@ cktsim = (function() { ...@@ -969,7 +954,6 @@ cktsim = (function() {
for (var j = 0; j < m; j++) for (var j = 0; j < m; j++)
dest[i][j] = src[i][j]; dest[i][j] = src[i][j];
} }
// Copy and transpose A -> using the bounds of A // Copy and transpose A -> using the bounds of A
function mat_copy_transposed(src,dest) { function mat_copy_transposed(src,dest) {
var n = src.length; var n = src.length;
...@@ -989,7 +973,7 @@ cktsim = (function() { ...@@ -989,7 +973,7 @@ cktsim = (function() {
var Nc = Mo[0].length; // Number of columns var Nc = Mo[0].length; // Number of columns
var temp,i,j; var temp,i,j;
// Make a copy to avoid overwriting // Make a copy to avoid overwriting
M = mat_make(Nr, Nc); var M = mat_make(Nr, Nc);
mat_copy(Mo,M); mat_copy(Mo,M);
// Find matrix maximum entry // Find matrix maximum entry
...@@ -1034,7 +1018,6 @@ cktsim = (function() { ...@@ -1034,7 +1018,6 @@ cktsim = (function() {
} }
} }
// return the rank
return the_rank; return the_rank;
} }
...@@ -1043,7 +1026,7 @@ cktsim = (function() { ...@@ -1043,7 +1026,7 @@ cktsim = (function() {
// M should have the extra column! // M should have the extra column!
// Almost everything is in-lined for speed, sigh. // Almost everything is in-lined for speed, sigh.
function mat_solve_rq(M, rhs) { function mat_solve_rq(M, rhs) {
var scale;
var Nr = M.length; // Number of rows var Nr = M.length; // Number of rows
var Nc = M[0].length; // Number of columns var Nc = M[0].length; // Number of columns
...@@ -1076,7 +1059,7 @@ cktsim = (function() { ...@@ -1076,7 +1059,7 @@ cktsim = (function() {
} }
// Calculate row norm, save if this is first (largest) // Calculate row norm, save if this is first (largest)
row_norm = Math.sqrt(maxsumsq); var row_norm = Math.sqrt(maxsumsq);
if (row == 0) mat_scale = row_norm; if (row == 0) mat_scale = row_norm;
// Check for all zero rows // Check for all zero rows
...@@ -1087,7 +1070,6 @@ cktsim = (function() { ...@@ -1087,7 +1070,6 @@ cktsim = (function() {
break; break;
} }
// Nonzero row, eliminate from rows below // Nonzero row, eliminate from rows below
var Mr = M[row]; var Mr = M[row];
for (var col = Nc-1; col >= 0; --col) // Scale rhs also for (var col = Nc-1; col >= 0; --col) // Scale rhs also
...@@ -1113,7 +1095,6 @@ cktsim = (function() { ...@@ -1113,7 +1095,6 @@ cktsim = (function() {
} }
} }
// Return solution.
return x; return x;
} }
...@@ -1169,7 +1150,6 @@ cktsim = (function() { ...@@ -1169,7 +1150,6 @@ cktsim = (function() {
x[i] = temp/M[i][i]; x[i] = temp/M[i][i];
} }
// return solution
return x; return x;
} }
...@@ -1286,7 +1266,6 @@ cktsim = (function() { ...@@ -1286,7 +1266,6 @@ cktsim = (function() {
return result*multiplier; return result*multiplier;
} }
} }
// read decimal integer or floating-point number // read decimal integer or floating-point number
while (true) { while (true) {
if (s.charAt(index) >= '0' && s.charAt(index) <= '9') if (s.charAt(index) >= '0' && s.charAt(index) <= '9')
...@@ -1378,7 +1357,7 @@ cktsim = (function() { ...@@ -1378,7 +1357,7 @@ cktsim = (function() {
function parse_source(v) { function parse_source(v) {
// generic parser: parse v as either <value> or <fun>(<value>,...) // generic parser: parse v as either <value> or <fun>(<value>,...)
var src = new Object(); var src = {};
src.period = 0; // Default not periodic src.period = 0; // Default not periodic
src.value = function(t) { return 0; } // overridden below src.value = function(t) { return 0; } // overridden below
src.inflection_point = function(t) { return undefined; }; // may be overridden below src.inflection_point = function(t) { return undefined; }; // may be overridden below
...@@ -1590,7 +1569,6 @@ cktsim = (function() { ...@@ -1590,7 +1569,6 @@ cktsim = (function() {
function VSource(npos,nneg,branch,v) { function VSource(npos,nneg,branch,v) {
Device.call(this); Device.call(this);
this.src = parse_source(v); this.src = parse_source(v);
this.npos = npos; this.npos = npos;
this.nneg = nneg; this.nneg = nneg;
...@@ -1630,7 +1608,6 @@ cktsim = (function() { ...@@ -1630,7 +1608,6 @@ cktsim = (function() {
function ISource(npos,nneg,v) { function ISource(npos,nneg,v) {
Device.call(this); Device.call(this);
this.src = parse_source(v); this.src = parse_source(v);
this.npos = npos; this.npos = npos;
this.nneg = nneg; this.nneg = nneg;
...@@ -1829,7 +1806,6 @@ cktsim = (function() { ...@@ -1829,7 +1806,6 @@ cktsim = (function() {
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Simple Voltage-Controlled Voltage Source Op Amp model // Simple Voltage-Controlled Voltage Source Op Amp model
...@@ -1849,7 +1825,6 @@ cktsim = (function() { ...@@ -1849,7 +1825,6 @@ cktsim = (function() {
Opamp.prototype = new Device(); Opamp.prototype = new Device();
Opamp.prototype.constructor = Opamp; Opamp.prototype.constructor = Opamp;
Opamp.prototype.load_linear = function(ckt) { Opamp.prototype.load_linear = function(ckt) {
// MNA stamp for VCVS: 1/A(v(no) - v(ng)) - (v(np)-v(nn))) = 0. // MNA stamp for VCVS: 1/A(v(no) - v(ng)) - (v(np)-v(nn))) = 0.
var invA = 1.0/this.gain; var invA = 1.0/this.gain;
...@@ -1872,14 +1847,12 @@ cktsim = (function() { ...@@ -1872,14 +1847,12 @@ cktsim = (function() {
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Simplified MOS FET with no bulk connection and no body effect. // Simplified MOS FET with no bulk connection and no body effect.
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
function Fet(d,g,s,ratio,name,type) { function Fet(d,g,s,ratio,name,type) {
Device.call(this); Device.call(this);
this.d = d; this.d = d;
...@@ -2023,16 +1996,6 @@ function add_schematic_handler(other_onload) { ...@@ -2023,16 +1996,6 @@ function add_schematic_handler(other_onload) {
update_schematics(); update_schematics();
} }
} }
/*
* THK: Attaching update_schematic to window.onload is rather presumptuous...
* The function is called for EVERY page load, whether in courseware or in
* course info, in 6.002x or the public health course. It is also redundant
* because courseware includes an explicit call to update_schematic after
* each ajax exchange. In this case, calling update_schematic twice appears
* to contribute to a bug in Firefox that does not render the schematic
* properly depending on timing.
*/
//window.onload = add_schematic_handler(window.onload);
// ask each schematic input widget to update its value field for submission // ask each schematic input widget to update its value field for submission
function prepare_schematics() { function prepare_schematics() {
...@@ -2042,20 +2005,18 @@ function prepare_schematics() { ...@@ -2042,20 +2005,18 @@ function prepare_schematics() {
} }
schematic = (function() { schematic = (function() {
background_style = 'rgb(220,220,220)'; var background_style = 'rgb(220,220,220)';
element_style = 'rgb(255,255,255)'; var element_style = 'rgb(255,255,255)';
thumb_style = 'rgb(128,128,128)'; var thumb_style = 'rgb(128,128,128)';
normal_style = 'rgb(0,0,0)'; // default drawing color var normal_style = 'rgb(0,0,0)'; // default drawing color
component_style = 'rgb(64,64,255)'; // color for unselected components var component_style = 'rgb(64,64,255)'; // color for unselected components
selected_style = 'rgb(64,255,64)'; // highlight color for selected components var selected_style = 'rgb(64,255,64)'; // highlight color for selected components
grid_style = "rgb(128,128,128)"; var grid_style = "rgb(128,128,128)";
annotation_style = 'rgb(255,64,64)'; // color for diagram annotations var annotation_style = 'rgb(255,64,64)'; // color for diagram annotations
var property_size = 5; // point size for Component property text
property_size = 5; // point size for Component property text var annotation_size = 6; // point size for diagram annotations
annotation_size = 6; // point size for diagram annotations
var parts_map = {
// list of all the defined parts
parts_map = {
'g': [Ground, 'Ground connection'], 'g': [Ground, 'Ground connection'],
'L': [Label, 'Node label'], 'L': [Label, 'Node label'],
'v': [VSource, 'Voltage source'], 'v': [VSource, 'Voltage source'],
...@@ -2093,7 +2054,6 @@ schematic = (function() { ...@@ -2093,7 +2054,6 @@ schematic = (function() {
if (this.origin_y == undefined) this.origin_y = 0; if (this.origin_y == undefined) this.origin_y = 0;
this.cursor_x = 0; this.cursor_x = 0;
this.cursor_y = 0; this.cursor_y = 0;
this.window_list = []; // list of pop-up windows in increasing z order this.window_list = []; // list of pop-up windows in increasing z order
// use user-supplied list of parts if supplied // use user-supplied list of parts if supplied
...@@ -2101,7 +2061,7 @@ schematic = (function() { ...@@ -2101,7 +2061,7 @@ schematic = (function() {
this.edits_allowed = true; this.edits_allowed = true;
var parts = input.getAttribute('parts'); var parts = input.getAttribute('parts');
if (parts == undefined || parts == 'None') { if (parts == undefined || parts == 'None') {
parts = new Array(); parts = [];
for (var p in parts_map) parts.push(p); for (var p in parts_map) parts.push(p);
} else if (parts == '') { } else if (parts == '') {
this.edits_allowed = false; this.edits_allowed = false;
...@@ -2138,7 +2098,7 @@ schematic = (function() { ...@@ -2138,7 +2098,7 @@ schematic = (function() {
this.submit_analyses = undefined; this.submit_analyses = undefined;
// toolbar // toolbar
this.tools = new Array(); this.tools = [];
this.toolbar = []; this.toolbar = [];
/* DISABLE HELP BUTTON (target URL not consistent with multicourse hierarchy) -- SJSU /* DISABLE HELP BUTTON (target URL not consistent with multicourse hierarchy) -- SJSU
...@@ -2233,13 +2193,11 @@ schematic = (function() { ...@@ -2233,13 +2193,11 @@ schematic = (function() {
this.status_div.style.height = status_height + 'px'; this.status_div.style.height = status_height + 'px';
} else this.status_div = undefined; } else this.status_div = undefined;
this.connection_points = new Array(); // location string => list of cp's this.connection_points = []; // location string => list of cp's
this.components = []; this.components = [];
this.dragging = false; this.dragging = false;
this.select_rect = undefined; this.select_rect = undefined;
this.wire = undefined; this.wire = undefined;
this.operating_point = undefined; // result from DC analysis this.operating_point = undefined; // result from DC analysis
this.dc_results = undefined; // saved analysis results for submission this.dc_results = undefined; // saved analysis results for submission
this.ac_results = undefined; // saved analysis results for submission this.ac_results = undefined; // saved analysis results for submission
...@@ -2339,13 +2297,12 @@ schematic = (function() { ...@@ -2339,13 +2297,12 @@ schematic = (function() {
this.zoomall(); this.zoomall();
} }
part_w = 42; // size of a parts bin compartment var part_w = 42; // size of a parts bin compartment
part_h = 42; var part_h = 42;
status_height = 18; var status_height = 18;
Schematic.prototype.add_component = function(new_c) { Schematic.prototype.add_component = function(new_c) {
this.components.push(new_c); this.components.push(new_c);
// create undoable edit record here // create undoable edit record here
} }
...@@ -2358,7 +2315,6 @@ schematic = (function() { ...@@ -2358,7 +2315,6 @@ schematic = (function() {
return this.connection_points[cp.location]; return this.connection_points[cp.location];
} }
// add connection point to list of connection points at that location
Schematic.prototype.add_connection_point = function(cp) { Schematic.prototype.add_connection_point = function(cp) {
var cplist = this.connection_points[cp.location]; var cplist = this.connection_points[cp.location];
if (cplist) cplist.push(cp); if (cplist) cplist.push(cp);
...@@ -2367,11 +2323,9 @@ schematic = (function() { ...@@ -2367,11 +2323,9 @@ schematic = (function() {
this.connection_points[cp.location] = cplist; this.connection_points[cp.location] = cplist;
} }
// return list of conincident connection points
return cplist; return cplist;
} }
// remove connection point from the list points at the old location
Schematic.prototype.remove_connection_point = function(cp,old_location) { Schematic.prototype.remove_connection_point = function(cp,old_location) {
// remove cp from list at old location // remove cp from list at old location
var cplist = this.connection_points[old_location]; var cplist = this.connection_points[old_location];
...@@ -2387,13 +2341,11 @@ schematic = (function() { ...@@ -2387,13 +2341,11 @@ schematic = (function() {
} }
} }
// connection point has changed location: remove, then add
Schematic.prototype.update_connection_point = function(cp,old_location) { Schematic.prototype.update_connection_point = function(cp,old_location) {
this.remove_connection_point(cp,old_location); this.remove_connection_point(cp,old_location);
return this.add_connection_point(cp); return this.add_connection_point(cp);
} }
// add a wire to the schematic
Schematic.prototype.add_wire = function(x1,y1,x2,y2) { Schematic.prototype.add_wire = function(x1,y1,x2,y2) {
var new_wire = new Wire(x1,y1,x2,y2); var new_wire = new Wire(x1,y1,x2,y2);
new_wire.add(this); new_wire.add(this);
...@@ -2464,7 +2416,6 @@ schematic = (function() { ...@@ -2464,7 +2416,6 @@ schematic = (function() {
Schematic.prototype.unselect_all = function(which) { Schematic.prototype.unselect_all = function(which) {
this.operating_point = undefined; // remove annotations this.operating_point = undefined; // remove annotations
for (var i = this.components.length - 1; i >= 0; --i) for (var i = this.components.length - 1; i >= 0; --i)
if (i != which) this.components[i].set_select(false); if (i != which) this.components[i].set_select(false);
} }
...@@ -2489,7 +2440,6 @@ schematic = (function() { ...@@ -2489,7 +2440,6 @@ schematic = (function() {
if (component.selected) component.move_end(); if (component.selected) component.move_end();
} }
this.dragging = false; this.dragging = false;
this.clean_up_wires(); this.clean_up_wires();
this.redraw_background(); this.redraw_background();
} }
...@@ -2509,11 +2459,6 @@ schematic = (function() { ...@@ -2509,11 +2459,6 @@ schematic = (function() {
this.origin_x += cx*(this.scale - nscale); this.origin_x += cx*(this.scale - nscale);
this.origin_y += cy*(this.scale - nscale); this.origin_y += cy*(this.scale - nscale);
this.scale = nscale; this.scale = nscale;
//this.origin_x = cx - this.width/(2*this.scale);
//this.origin_y = cy - this.height/(2*this.scale);
this.redraw_background(); this.redraw_background();
} }
...@@ -2522,15 +2467,14 @@ schematic = (function() { ...@@ -2522,15 +2467,14 @@ schematic = (function() {
this.redraw_background(); this.redraw_background();
} }
zoom_factor = 1.25; // scaling is some power of zoom_factor var zoom_factor = 1.25; // scaling is some power of zoom_factor
zoom_min = 0.5; var zoom_min = 0.5;
zoom_max = 4.0; var zoom_max = 4.0;
origin_min = -200; // in grids var origin_min = -200; // in grids
origin_max = 200; var origin_max = 200;
Schematic.prototype.zoomin = function() { Schematic.prototype.zoomin = function() {
var nscale = this.scale * zoom_factor; var nscale = this.scale * zoom_factor;
if (nscale < zoom_max) { if (nscale < zoom_max) {
// keep center of view unchanged // keep center of view unchanged
this.origin_x += (this.width/2)*(1.0/this.scale - 1.0/nscale); this.origin_x += (this.width/2)*(1.0/this.scale - 1.0/nscale);
...@@ -2542,7 +2486,6 @@ schematic = (function() { ...@@ -2542,7 +2486,6 @@ schematic = (function() {
Schematic.prototype.zoomout = function() { Schematic.prototype.zoomout = function() {
var nscale = this.scale / zoom_factor; var nscale = this.scale / zoom_factor;
if (nscale > zoom_min) { if (nscale > zoom_min) {
// keep center of view unchanged // keep center of view unchanged
this.origin_x += (this.width/2)*(1.0/this.scale - 1.0/nscale); this.origin_x += (this.width/2)*(1.0/this.scale - 1.0/nscale);
...@@ -2632,7 +2575,6 @@ schematic = (function() { ...@@ -2632,7 +2575,6 @@ schematic = (function() {
new_c.add(this); new_c.add(this);
} }
// see what we've wrought
this.redraw(); this.redraw();
} }
...@@ -2647,7 +2589,6 @@ schematic = (function() { ...@@ -2647,7 +2589,6 @@ schematic = (function() {
// use default value if no schematic info in value // use default value if no schematic info in value
if (value == undefined || value.indexOf('[') == -1) if (value == undefined || value.indexOf('[') == -1)
value = initial_value; value = initial_value;
if (value && value.indexOf('[') != -1) { if (value && value.indexOf('[') != -1) {
// convert string value into data structure // convert string value into data structure
var json = JSON.parse(value); var json = JSON.parse(value);
...@@ -2656,12 +2597,6 @@ schematic = (function() { ...@@ -2656,12 +2597,6 @@ schematic = (function() {
for (var i = json.length - 1; i >= 0; --i) { for (var i = json.length - 1; i >= 0; --i) {
var c = json[i]; var c = json[i];
if (c[0] == 'view') { if (c[0] == 'view') {
// special hack: view component lets us recreate view
// ignore saved view parameters as they sometimes screw students
//this.origin_x = c[1];
//this.origin_y = c[2];
//this.scale = c[3];
//this.ac_npts = c[4];
this.ac_fstart = c[5]; this.ac_fstart = c[5];
this.ac_fstop = c[6]; this.ac_fstop = c[6];
this.ac_source_name = c[7]; this.ac_source_name = c[7];
...@@ -2684,20 +2619,15 @@ schematic = (function() { ...@@ -2684,20 +2619,15 @@ schematic = (function() {
var coords = c[1]; var coords = c[1];
var properties = c[2]; var properties = c[2];
// make the part
var part = new parts_map[type][0](coords[0],coords[1],coords[2]); var part = new parts_map[type][0](coords[0],coords[1],coords[2]);
// give it its properties
for (var name in properties) for (var name in properties)
part.properties[name] = properties[name]; part.properties[name] = properties[name];
// add component to the diagram
part.add(this); part.add(this);
} }
} }
} }
// see what we've got!
this.redraw_background(); this.redraw_background();
} }
...@@ -2721,7 +2651,6 @@ schematic = (function() { ...@@ -2721,7 +2651,6 @@ schematic = (function() {
this.components[i].label_connections(); this.components[i].label_connections();
} }
// generate a new label
Schematic.prototype.get_next_label = function() { Schematic.prototype.get_next_label = function() {
// generate next label in sequence // generate next label in sequence
this.next_label += 1; this.next_label += 1;
...@@ -2746,7 +2675,6 @@ schematic = (function() { ...@@ -2746,7 +2675,6 @@ schematic = (function() {
this.input.value = JSON.stringify(this.json_with_analyses()); this.input.value = JSON.stringify(this.json_with_analyses());
} }
// produce a JSON representation of the diagram
Schematic.prototype.json = function() { Schematic.prototype.json = function() {
var json = []; var json = [];
...@@ -2764,7 +2692,6 @@ schematic = (function() { ...@@ -2764,7 +2692,6 @@ schematic = (function() {
return json; return json;
} }
// produce a JSON representation of the diagram
Schematic.prototype.json_with_analyses = function() { Schematic.prototype.json_with_analyses = function() {
var json = this.json(); var json = this.json();
...@@ -2847,8 +2774,7 @@ schematic = (function() { ...@@ -2847,8 +2774,7 @@ schematic = (function() {
return; return;
} }
var fields = new Array(); var fields = [];
//fields[npts_lbl] = build_input('text',10,this.ac_npts);
fields[fstart_lbl] = build_input('text',10,this.ac_fstart); fields[fstart_lbl] = build_input('text',10,this.ac_fstart);
fields[fstop_lbl] = build_input('text',10,this.ac_fstop); fields[fstop_lbl] = build_input('text',10,this.ac_fstop);
fields[source_name_lbl] = build_input('text',10,this.ac_source_name); fields[source_name_lbl] = build_input('text',10,this.ac_source_name);
...@@ -2861,7 +2787,6 @@ schematic = (function() { ...@@ -2861,7 +2787,6 @@ schematic = (function() {
var sch = content.sch; var sch = content.sch;
// retrieve parameters, remember for next time // retrieve parameters, remember for next time
//sch.ac_npts = content.fields[npts_lbl].value;
sch.ac_fstart = content.fields[fstart_lbl].value; sch.ac_fstart = content.fields[fstart_lbl].value;
sch.ac_fstop = content.fields[fstop_lbl].value; sch.ac_fstop = content.fields[fstop_lbl].value;
sch.ac_source_name = content.fields[source_name_lbl].value; sch.ac_source_name = content.fields[source_name_lbl].value;
...@@ -2873,9 +2798,7 @@ schematic = (function() { ...@@ -2873,9 +2798,7 @@ schematic = (function() {
}); });
} }
// perform ac analysis
Schematic.prototype.ac_analysis = function(npts,fstart,fstop,ac_source_name) { Schematic.prototype.ac_analysis = function(npts,fstart,fstop,ac_source_name) {
// run the analysis
var ckt = this.extract_circuit(); var ckt = this.extract_circuit();
if (ckt === null) return; if (ckt === null) return;
var results = ckt.ac(npts,fstart,fstop,ac_source_name); var results = ckt.ac(npts,fstart,fstop,ac_source_name);
...@@ -2889,7 +2812,6 @@ schematic = (function() { ...@@ -2889,7 +2812,6 @@ schematic = (function() {
for (var i = x_values.length - 1; i >= 0; --i) for (var i = x_values.length - 1; i >= 0; --i)
x_values[i] = Math.log(x_values[i])/Math.LN10; x_values[i] = Math.log(x_values[i])/Math.LN10;
if (this.submit_analyses != undefined) { if (this.submit_analyses != undefined) {
var submit = this.submit_analyses['ac']; var submit = this.submit_analyses['ac'];
if (submit != undefined) { if (submit != undefined) {
...@@ -2919,7 +2841,6 @@ schematic = (function() { ...@@ -2919,7 +2841,6 @@ schematic = (function() {
var y_values = []; // list of [color, result_array] var y_values = []; // list of [color, result_array]
var z_values = []; // list of [color, result_array] var z_values = []; // list of [color, result_array]
var probes = this.find_probes(); var probes = this.find_probes();
var probe_maxv = []; var probe_maxv = [];
var probe_color = []; var probe_color = [];
...@@ -2931,8 +2852,8 @@ schematic = (function() { ...@@ -2931,8 +2852,8 @@ schematic = (function() {
var v = results[label]; var v = results[label];
probe_maxv[i] = array_max(v); // magnitudes always > 0 probe_maxv[i] = array_max(v); // magnitudes always > 0
} }
var all_max = array_max(probe_maxv);
var all_max = array_max(probe_maxv);
if (all_max < 1.0e-16) { if (all_max < 1.0e-16) {
alert('Zero ac response, -infinity on DB scale.'); alert('Zero ac response, -infinity on DB scale.');
} else { } else {
...@@ -2950,7 +2871,6 @@ schematic = (function() { ...@@ -2950,7 +2871,6 @@ schematic = (function() {
var color = probes[i][0]; var color = probes[i][0];
var label = probes[i][1]; var label = probes[i][1];
var offset = cktsim.parse_number(probes[i][2]); var offset = cktsim.parse_number(probes[i][2]);
var v = results[label]; var v = results[label];
// convert values into dB relative to source amplitude // convert values into dB relative to source amplitude
var v_max = 1; var v_max = 1;
...@@ -2977,15 +2897,13 @@ schematic = (function() { ...@@ -2977,15 +2897,13 @@ schematic = (function() {
var npts_lbl = 'Minimum number of timepoints'; var npts_lbl = 'Minimum number of timepoints';
var tstop_lbl = 'Stop Time (seconds)'; var tstop_lbl = 'Stop Time (seconds)';
var probes = this.find_probes(); var probes = this.find_probes();
if (probes.length == 0) { if (probes.length == 0) {
alert("Transient Analysis: there are no probes in the diagram!"); alert("Transient Analysis: there are no probes in the diagram!");
return; return;
} }
var fields = new Array(); var fields = [];
//fields[npts_lbl] = build_input('text',10,this.tran_npts);
fields[tstop_lbl] = build_input('text',10,this.tran_tstop); fields[tstop_lbl] = build_input('text',10,this.tran_tstop);
var content = build_table(fields); var content = build_table(fields);
...@@ -2998,7 +2916,6 @@ schematic = (function() { ...@@ -2998,7 +2916,6 @@ schematic = (function() {
if (ckt === null) return; if (ckt === null) return;
// retrieve parameters, remember for next time // retrieve parameters, remember for next time
//sch.tran_npts = content.fields[npts_lbl].value;
sch.tran_tstop = content.fields[tstop_lbl].value; sch.tran_tstop = content.fields[tstop_lbl].value;
// gather a list of nodes that are being probed. These // gather a list of nodes that are being probed. These
...@@ -3109,7 +3026,6 @@ schematic = (function() { ...@@ -3109,7 +3026,6 @@ schematic = (function() {
} }
} }
// update diagram
this.redraw_background(); this.redraw_background();
} }
...@@ -3161,7 +3077,6 @@ schematic = (function() { ...@@ -3161,7 +3077,6 @@ schematic = (function() {
} }
} }
this.unsel_bbox = [min_x,min_y,max_x,max_y]; this.unsel_bbox = [min_x,min_y,max_x,max_y];
this.redraw(); // background changed, redraw on screen this.redraw(); // background changed, redraw on screen
} }
...@@ -3228,7 +3143,7 @@ schematic = (function() { ...@@ -3228,7 +3143,7 @@ schematic = (function() {
this.message(this.operating_point); this.message(this.operating_point);
else { else {
// make a copy of the operating_point info so we can mess with it // make a copy of the operating_point info so we can mess with it
var temp = new Array(); var temp = [];
for (var i in this.operating_point) temp[i] = this.operating_point[i]; for (var i in this.operating_point) temp[i] = this.operating_point[i];
// run through connection points displaying (once) the voltage // run through connection points displaying (once) the voltage
...@@ -3355,7 +3270,6 @@ schematic = (function() { ...@@ -3355,7 +3270,6 @@ schematic = (function() {
// now compute relative position of click within the canvas // now compute relative position of click within the canvas
this.mouse_x = event.pageX - totalOffsetX; this.mouse_x = event.pageX - totalOffsetX;
this.mouse_y = event.pageY - totalOffsetY; this.mouse_y = event.pageY - totalOffsetY;
this.page_x = event.pageX; this.page_x = event.pageX;
this.page_y = event.pageY; this.page_y = event.pageY;
} }
...@@ -3594,12 +3508,10 @@ schematic = (function() { ...@@ -3594,12 +3508,10 @@ schematic = (function() {
// update moving corner of selection rectangle // update moving corner of selection rectangle
sch.select_rect[2] = sch.canvas.mouse_x; sch.select_rect[2] = sch.canvas.mouse_x;
sch.select_rect[3] = sch.canvas.mouse_y; sch.select_rect[3] = sch.canvas.mouse_y;
//sch.message(sch.select_rect.toString());
} }
// just redraw dynamic components // just redraw dynamic components
sch.redraw(); sch.redraw();
//sch.message(sch.canvas.page_x + ',' + sch.canvas.page_y + ';' + sch.canvas.mouse_x + ',' + sch.canvas.mouse_y + ';' + sch.cursor_x + ',' + sch.cursor_y);
return false; return false;
} }
...@@ -3737,7 +3649,6 @@ schematic = (function() { ...@@ -3737,7 +3649,6 @@ schematic = (function() {
body.style.padding = '5px'; body.style.padding = '5px';
dialog.appendChild(body); dialog.appendChild(body);
// OK button
var ok_button = document.createElement('span'); var ok_button = document.createElement('span');
ok_button.appendChild(document.createTextNode('OK')); ok_button.appendChild(document.createTextNode('OK'));
ok_button.dialog = dialog; // for the handler to use ok_button.dialog = dialog; // for the handler to use
...@@ -3747,7 +3658,6 @@ schematic = (function() { ...@@ -3747,7 +3658,6 @@ schematic = (function() {
ok_button.style.padding = '5px'; ok_button.style.padding = '5px';
ok_button.style.margin = '10px'; ok_button.style.margin = '10px';
// cancel button
var cancel_button = document.createElement('span'); var cancel_button = document.createElement('span');
cancel_button.appendChild(document.createTextNode('Cancel')); cancel_button.appendChild(document.createTextNode('Cancel'));
cancel_button.dialog = dialog; // for the handler to use cancel_button.dialog = dialog; // for the handler to use
...@@ -3770,7 +3680,6 @@ schematic = (function() { ...@@ -3770,7 +3680,6 @@ schematic = (function() {
this.window(title,dialog); this.window(title,dialog);
} }
// callback when user click "Cancel" in a dialog
function dialog_cancel(event) { function dialog_cancel(event) {
if (!event) event = window.event; if (!event) event = window.event;
var dialog = (window.event) ? event.srcElement.dialog : event.target.dialog; var dialog = (window.event) ? event.srcElement.dialog : event.target.dialog;
...@@ -3778,14 +3687,12 @@ schematic = (function() { ...@@ -3778,14 +3687,12 @@ schematic = (function() {
window_close(dialog.win); window_close(dialog.win);
} }
// callback when user click "OK" in a dialog
function dialog_okay(event) { function dialog_okay(event) {
if (!event) event = window.event; if (!event) event = window.event;
var dialog = (window.event) ? event.srcElement.dialog : event.target.dialog; var dialog = (window.event) ? event.srcElement.dialog : event.target.dialog;
window_close(dialog.win); window_close(dialog.win);
// invoke the callback with the dialog contents as the argument
if (dialog.callback) dialog.callback(dialog.content); if (dialog.callback) dialog.callback(dialog.content);
} }
...@@ -3824,7 +3731,6 @@ schematic = (function() { ...@@ -3824,7 +3731,6 @@ schematic = (function() {
return tbl; return tbl;
} }
// build an input field
function build_input(type,size,value) { function build_input(type,size,value) {
var input = document.createElement('input'); var input = document.createElement('input');
input.type = type; input.type = type;
...@@ -3890,7 +3796,6 @@ schematic = (function() { ...@@ -3890,7 +3796,6 @@ schematic = (function() {
// add to DOM // add to DOM
win.style.background = 'white'; win.style.background = 'white';
//win.style.zIndex = '1000';
win.style.position = 'absolute'; win.style.position = 'absolute';
win.style.left = win.left + 'px'; win.style.left = win.left + 'px';
win.style.top = win.top + 'px'; win.style.top = win.top + 'px';
...@@ -4076,17 +3981,17 @@ schematic = (function() { ...@@ -4076,17 +3981,17 @@ schematic = (function() {
} }
} }
help_icon = 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///wAAAAAAACH5BAkAAAIAIf8LSUNDUkdCRzEwMTL/AAAHqGFwcGwCIAAAbW50clJHQiBYWVogB9kAAgAZAAsAGgALYWNzcEFQUEwAAAAAYXBwbAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALZGVzYw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wD//////yH5BAEAAAcALAAAAAAQABAAAAQu8MhJqz1g5qs7lxv2gRkQfuWomarXEgDRHjJhf3YtyRav0xcfcFgR0nhB5OwTAQA7'; var cut_icon = 'data:image/gif;base64,R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAAcALAAAAAAQABAAAAQu8MhJqz1g5qs7lxv2gRkQfuWomarXEgDRHjJhf3YtyRav0xcfcFgR0nhB5OwTAQA7';
copy_icon = 'data:image/gif;base64,R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAAcALAAAAAAQABAAAAQ+8MhJ6wE4Wwqef9gmdV8HiKZJrCz3ecS7TikWfzExvk+M9a0a4MbTkXCgTMeoHPJgG5+yF31SLazsTMTtViIAOw=='; var copy_icon = 'data:image/gif;base64,R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAAcALAAAAAAQABAAAAQ+8MhJ6wE4Wwqef9gmdV8HiKZJrCz3ecS7TikWfzExvk+M9a0a4MbTkXCgTMeoHPJgG5+yF31SLazsTMTtViIAOw==';
paste_icon = 'data:image/gif;base64,R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAAcALAAAAAAQABAAAARL8MhJqwUYWJnxWp3GDcgAgCdQIqLKXmVLhhnyHiqpr7rME8AgocVDEB5IJHD0SyofBFzxGIQGAbvB0ZkcTq1CKK6z5YorwnR0w44AADs='; var paste_icon = 'data:image/gif;base64,R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAAcALAAAAAAQABAAAARL8MhJqwUYWJnxWp3GDcgAgCdQIqLKXmVLhhnyHiqpr7rME8AgocVDEB5IJHD0SyofBFzxGIQGAbvB0ZkcTq1CKK6z5YorwnR0w44AADs=';
close_icon = 'data:image/gif;base64,R0lGODlhEAAQAMQAAGtra/f3/62tre/v9+bm787O1pycnHNzc6WlpcXFxd7e3tbW1nt7e7W1te/v74SEhMXFzmNjY+bm5v///87OzgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAVt4DRMZGmSwRQQBUS9MAwRIyQ5Uq7neEFSDtxOF4T8cobIQaE4RAQ5yjHHiCCSD510QtFGvoCFdppDfBu7bYzy+D7WP5ggAgA8Y3FKwi5IAhIweW1vbBGEWy5rilsFi2tGAwSJixAFBCkpJ5ojIQA7'; var close_icon = 'data:image/gif;base64,R0lGODlhEAAQAMQAAGtra/f3/62tre/v9+bm787O1pycnHNzc6WlpcXFxd7e3tbW1nt7e7W1te/v74SEhMXFzmNjY+bm5v///87OzgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAVt4DRMZGmSwRQQBUS9MAwRIyQ5Uq7neEFSDtxOF4T8cobIQaE4RAQ5yjHHiCCSD510QtFGvoCFdppDfBu7bYzy+D7WP5ggAgA8Y3FKwi5IAhIweW1vbBGEWy5rilsFi2tGAwSJixAFBCkpJ5ojIQA7';
grid_icon = 'data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAP///zAwYT09bpGRqZ6et5iYsKWlvbi40MzM5cXF3czM5OHh5tTU2fDw84uMom49DbWKcfLy8g0NDcDAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABQALAAAAAAQABAAAAUtICWOZGmeKDCqIlu68AvMdO2ueHvGuslTN6Bt6MsBd8Zg77hsDW3FpRJFrYpCADs='; var grid_icon = 'data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAP///zAwYT09bpGRqZ6et5iYsKWlvbi40MzM5cXF3czM5OHh5tTU2fDw84uMom49DbWKcfLy8g0NDcDAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABQALAAAAAAQABAAAAUtICWOZGmeKDCqIlu68AvMdO2ueHvGuslTN6Bt6MsBd8Zg77hsDW3FpRJFrYpCADs=';
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
...@@ -4108,7 +4013,6 @@ schematic = (function() { ...@@ -4108,7 +4013,6 @@ schematic = (function() {
var gt = function (a, b) { return a >= b; }; var gt = function (a, b) { return a >= b; };
var capmin = function (a, b) { return Math.min(a, b); }; var capmin = function (a, b) { return Math.min(a, b); };
var capmax = function (a, b) { return Math.max(a, b); }; var capmax = function (a, b) { return Math.max(a, b); };
var checkX = { thereYet: gt, cap: capmin }; var checkX = { thereYet: gt, cap: capmin };
var checkY = { thereYet: gt, cap: capmin }; var checkY = { thereYet: gt, cap: capmin };
...@@ -4491,14 +4395,14 @@ schematic = (function() { ...@@ -4491,14 +4395,14 @@ schematic = (function() {
} }
function array_max(a) { function array_max(a) {
max = -Infinity; var max = -Infinity;
for (var i = a.length - 1; i >= 0; --i) for (var i = a.length - 1; i >= 0; --i)
if (a[i] > max) max = a[i]; if (a[i] > max) max = a[i];
return max; return max;
} }
function array_min(a) { function array_min(a) {
min = Infinity; var min = Infinity;
for (var i = a.length - 1; i >= 0; --i) for (var i = a.length - 1; i >= 0; --i)
if (a[i] < min) min = a[i]; if (a[i] < min) min = a[i];
return min; return min;
...@@ -4883,7 +4787,7 @@ schematic = (function() { ...@@ -4883,7 +4787,7 @@ schematic = (function() {
this.y = y; this.y = y;
this.rotation = rotation; this.rotation = rotation;
this.selected = false; this.selected = false;
this.properties = new Array(); this.properties = [];
this.bounding_box = [0,0,0,0]; // in device coords [left,top,right,bottom] this.bounding_box = [0,0,0,0]; // in device coords [left,top,right,bottom]
this.bbox = this.bounding_box; // in absolute coords this.bbox = this.bounding_box; // in absolute coords
this.connections = []; this.connections = [];
...@@ -5025,7 +4929,7 @@ schematic = (function() { ...@@ -5025,7 +4929,7 @@ schematic = (function() {
this.sch.draw_arc(c,nx,ny,radius,0,2*Math.PI,false,1,filled); this.sch.draw_arc(c,nx,ny,radius,0,2*Math.PI,false,1,filled);
} }
rot_angle = [ var rot_angle = [
0.0, // NORTH (identity) 0.0, // NORTH (identity)
Math.PI/2, // EAST (rot270) Math.PI/2, // EAST (rot270)
Math.PI, // SOUTH (rot180) Math.PI, // SOUTH (rot180)
...@@ -5056,7 +4960,7 @@ schematic = (function() { ...@@ -5056,7 +4960,7 @@ schematic = (function() {
} }
// result of rotating an alignment [rot*9 + align] // result of rotating an alignment [rot*9 + align]
aOrient = [ var aOrient = [
0, 1, 2, 3, 4, 5, 6, 7, 8, // NORTH (identity) 0, 1, 2, 3, 4, 5, 6, 7, 8, // NORTH (identity)
2, 5, 8, 1, 4, 7, 0, 3, 6, // EAST (rot270) 2, 5, 8, 1, 4, 7, 0, 3, 6, // EAST (rot270)
8, 7, 6, 5, 4, 3, 2, 1, 0, // SOUTH (rot180) 8, 7, 6, 5, 4, 3, 2, 1, 0, // SOUTH (rot180)
...@@ -5067,13 +4971,13 @@ schematic = (function() { ...@@ -5067,13 +4971,13 @@ schematic = (function() {
0, 3, 6, 1, 4, 7, 2, 5, 8 // RWEST (int-pos) 0, 3, 6, 1, 4, 7, 2, 5, 8 // RWEST (int-pos)
]; ];
textAlign = [ var textAlign = [
'left', 'center', 'right', 'left', 'center', 'right',
'left', 'center', 'right', 'left', 'center', 'right',
'left', 'center', 'right' 'left', 'center', 'right'
]; ];
textBaseline = [ var textBaseline = [
'top', 'top', 'top', 'top', 'top', 'top',
'middle', 'middle', 'middle', 'middle', 'middle', 'middle',
'bottom', 'bottom', 'bottom' 'bottom', 'bottom', 'bottom'
...@@ -5129,7 +5033,7 @@ schematic = (function() { ...@@ -5129,7 +5033,7 @@ schematic = (function() {
Component.prototype.edit_properties = function(x,y) { Component.prototype.edit_properties = function(x,y) {
if (this.near(x,y)) { if (this.near(x,y)) {
// make an <input> widget for each property // make an <input> widget for each property
var fields = new Array(); var fields = [];
for (var i in this.properties) for (var i in this.properties)
// underscore at beginning of property name => system property // underscore at beginning of property name => system property
if (i.charAt(0) != '_') if (i.charAt(0) != '_')
...@@ -5148,7 +5052,6 @@ schematic = (function() { ...@@ -5148,7 +5052,6 @@ schematic = (function() {
} else return false; } else return false;
} }
// clear the labels on all connections
Component.prototype.clear_labels = function() { Component.prototype.clear_labels = function() {
for (var i = this.connections.length - 1; i >=0; --i) { for (var i = this.connections.length - 1; i >=0; --i) {
this.connections[i].clear_label(); this.connections[i].clear_label();
...@@ -5186,7 +5089,7 @@ schematic = (function() { ...@@ -5186,7 +5089,7 @@ schematic = (function() {
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
connection_point_radius = 2; var connection_point_radius = 2;
function ConnectionPoint(parent,x,y) { function ConnectionPoint(parent,x,y) {
this.parent = parent; this.parent = parent;
...@@ -5287,7 +5190,7 @@ schematic = (function() { ...@@ -5287,7 +5190,7 @@ schematic = (function() {
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
near_distance = 2; // how close to wire counts as "near by" var near_distance = 2; // how close to wire counts as "near by"
function Wire(x1,y1,x2,y2) { function Wire(x1,y1,x2,y2) {
// arbitrarily call x1,y1 the origin // arbitrarily call x1,y1 the origin
...@@ -5493,8 +5396,8 @@ schematic = (function() { ...@@ -5493,8 +5396,8 @@ schematic = (function() {
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
probe_colors = ['red','green','blue','cyan','magenta','yellow','black','x-axis']; var probe_colors = ['red','green','blue','cyan','magenta','yellow','black','x-axis'];
probe_colors_rgb = { var probe_colors_rgb = {
'red': 'rgb(255,64,64)', 'red': 'rgb(255,64,64)',
'green': 'rgb(64,255,64)', 'green': 'rgb(64,255,64)',
'blue': 'rgb(64,64,255)', 'blue': 'rgb(64,64,255)',
...@@ -5551,7 +5454,7 @@ schematic = (function() { ...@@ -5551,7 +5454,7 @@ schematic = (function() {
Probe.prototype.edit_properties = function(x,y) { Probe.prototype.edit_properties = function(x,y) {
if (inside(this.bbox,x,y)) { if (inside(this.bbox,x,y)) {
var fields = new Array(); var fields = [];
fields['Plot color'] = build_select(probe_colors,this.properties['color']); fields['Plot color'] = build_select(probe_colors,this.properties['color']);
fields['Plot offset'] = build_input('text',10,this.properties['offset']); fields['Plot offset'] = build_input('text',10,this.properties['offset']);
...@@ -5798,7 +5701,7 @@ schematic = (function() { ...@@ -5798,7 +5701,7 @@ schematic = (function() {
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
diode_types = ['normal','ideal']; var diode_types = ['normal','ideal'];
function Diode(x,y,rotation,name,area,type) { function Diode(x,y,rotation,name,area,type) {
Component.call(this,'d',x,y,rotation); Component.call(this,'d',x,y,rotation);
...@@ -5846,7 +5749,7 @@ schematic = (function() { ...@@ -5846,7 +5749,7 @@ schematic = (function() {
Diode.prototype.edit_properties = function(x,y) { Diode.prototype.edit_properties = function(x,y) {
if (inside(this.bbox,x,y)) { if (inside(this.bbox,x,y)) {
var fields = new Array(); var fields = [];
fields['name'] = build_input('text',10,this.properties['name']); fields['name'] = build_input('text',10,this.properties['name']);
fields['area'] = build_input('text',10,this.properties['area']); fields['area'] = build_input('text',10,this.properties['area']);
fields['type'] = build_select(diode_types,this.properties['type']); fields['type'] = build_select(diode_types,this.properties['type']);
...@@ -5895,7 +5798,6 @@ schematic = (function() { ...@@ -5895,7 +5798,6 @@ schematic = (function() {
this.draw_line(c,-8,16,-8,32); this.draw_line(c,-8,16,-8,32);
this.draw_line(c,-8,32,0,32); this.draw_line(c,-8,32,0,32);
this.draw_line(c,0,32,0,48); this.draw_line(c,0,32,0,48);
this.draw_line(c,-24,24,-12,24); this.draw_line(c,-24,24,-12,24);
this.draw_line(c,-12,16,-12,32); this.draw_line(c,-12,16,-12,32);
...@@ -5941,9 +5843,7 @@ schematic = (function() { ...@@ -5941,9 +5843,7 @@ schematic = (function() {
this.draw_line(c,-8,16,-8,32); this.draw_line(c,-8,16,-8,32);
this.draw_line(c,-8,32,0,32); this.draw_line(c,-8,32,0,32);
this.draw_line(c,0,32,0,48); this.draw_line(c,0,32,0,48);
this.draw_line(c,-24,24,-16,24); this.draw_line(c,-24,24,-16,24);
this.draw_circle(c,-14,24,2,false); this.draw_circle(c,-14,24,2,false);
this.draw_line(c,-12,16,-12,32); this.draw_line(c,-12,16,-12,32);
...@@ -6014,7 +5914,6 @@ schematic = (function() { ...@@ -6014,7 +5914,6 @@ schematic = (function() {
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function Source(x,y,rotation,name,type,value) { function Source(x,y,rotation,name,type,value) {
Component.call(this,type,x,y,rotation); Component.call(this,type,x,y,rotation);
this.properties['name'] = name; this.properties['name'] = name;
...@@ -6024,7 +5923,6 @@ schematic = (function() { ...@@ -6024,7 +5923,6 @@ schematic = (function() {
this.add_connection(0,48); this.add_connection(0,48);
this.bounding_box = [-12,0,12,48]; this.bounding_box = [-12,0,12,48];
this.update_coords(); this.update_coords();
this.content = document.createElement('div'); // used by edit_properties this.content = document.createElement('div'); // used by edit_properties
} }
Source.prototype = new Component(); Source.prototype = new Component();
...@@ -6041,15 +5939,10 @@ schematic = (function() { ...@@ -6041,15 +5939,10 @@ schematic = (function() {
this.draw_line(c,0,36,0,48); this.draw_line(c,0,36,0,48);
if (this.type == 'v') { // voltage source if (this.type == 'v') { // voltage source
//this.draw_text(c,'+',0,12,1,property_size);
//this.draw_text(c,'\u2013',0,36,7,property_size); // minus sign
// draw + and - // draw + and -
this.draw_line(c,0,15,0,21); this.draw_line(c,0,15,0,21);
this.draw_line(c,-3,18,3,18); this.draw_line(c,-3,18,3,18);
this.draw_line(c,-3,30,3,30); this.draw_line(c,-3,30,3,30);
// draw V
//this.draw_line(c,-3,20,0,28);
//this.draw_line(c,3,20,0,28);
} else if (this.type == 'i') { // current source } else if (this.type == 'i') { // current source
// draw arrow: pos to neg // draw arrow: pos to neg
this.draw_line(c,0,15,0,32); this.draw_line(c,0,15,0,32);
...@@ -6064,7 +5957,7 @@ schematic = (function() { ...@@ -6064,7 +5957,7 @@ schematic = (function() {
} }
// map source function name to labels for each source parameter // map source function name to labels for each source parameter
source_functions = { var source_functions = {
'dc': ['DC value'], 'dc': ['DC value'],
'impulse': ['Height', 'impulse': ['Height',
...@@ -6201,7 +6094,6 @@ schematic = (function() { ...@@ -6201,7 +6094,6 @@ schematic = (function() {
} else return false; } else return false;
} }
function VSource(x,y,rotation,name,value) { function VSource(x,y,rotation,name,value) {
Source.call(this,x,y,rotation,name,'v',value); Source.call(this,x,y,rotation,name,'v',value);
this.type = 'v'; this.type = 'v';
...@@ -6304,3 +6196,4 @@ schematic = (function() { ...@@ -6304,3 +6196,4 @@ schematic = (function() {
} }
return module; return module;
}()); }());
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment