Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ae3ed270
Commit
ae3ed270
authored
Feb 06, 2012
by
Kyle Fiedler
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
6e8afaa1
b15e7c19
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
182 additions
and
43 deletions
+182
-43
.DS_Store
+0
-0
js/cktsim.js
+90
-7
js/schematic.js
+74
-34
js/video_player.js
+18
-2
No files found.
.DS_Store
View file @
ae3ed270
No preview for this file type
js/cktsim.js
View file @
ae3ed270
...
@@ -96,10 +96,18 @@ cktsim = (function() {
...
@@ -96,10 +96,18 @@ cktsim = (function() {
// load circuit from JSON netlist (see schematic.js)
// load circuit from JSON netlist (see schematic.js)
Circuit
.
prototype
.
load_netlist
=
function
(
netlist
)
{
Circuit
.
prototype
.
load_netlist
=
function
(
netlist
)
{
// set up mapping for ground node always called '0' in JSON netlist
// set up mapping for all ground connections
this
.
node_map
[
'0'
]
=
this
.
gnd_node
();
for
(
var
i
=
netlist
.
length
-
1
;
i
>=
0
;
--
i
)
{
var
component
=
netlist
[
i
];
var
type
=
component
[
0
];
if
(
type
==
'g'
)
{
var
connections
=
component
[
3
];
this
.
node_map
[
connections
[
0
]]
=
this
.
gnd_node
();
}
}
// process each component in the JSON netlist (see schematic.js for format)
// process each component in the JSON netlist (see schematic.js for format)
var
found_ground
=
false
;
for
(
var
i
=
netlist
.
length
-
1
;
i
>=
0
;
--
i
)
{
for
(
var
i
=
netlist
.
length
-
1
;
i
>=
0
;
--
i
)
{
var
component
=
netlist
[
i
];
var
component
=
netlist
[
i
];
var
type
=
component
[
0
];
var
type
=
component
[
0
];
...
@@ -120,6 +128,7 @@ cktsim = (function() {
...
@@ -120,6 +128,7 @@ cktsim = (function() {
var
node
=
connections
[
j
];
var
node
=
connections
[
j
];
var
index
=
this
.
node_map
[
node
];
var
index
=
this
.
node_map
[
node
];
if
(
index
==
undefined
)
index
=
this
.
node
(
node
,
T_VOLTAGE
);
if
(
index
==
undefined
)
index
=
this
.
node
(
node
,
T_VOLTAGE
);
else
if
(
index
==
this
.
gnd_node
())
found_ground
=
true
;
connections
[
j
]
=
index
;
connections
[
j
]
=
index
;
}
}
...
@@ -137,12 +146,19 @@ cktsim = (function() {
...
@@ -137,12 +146,19 @@ cktsim = (function() {
else
if
(
type
==
'i'
)
// current source
else
if
(
type
==
'i'
)
// current source
this
.
i
(
connections
[
0
],
connections
[
1
],
properties
[
'value'
],
name
);
this
.
i
(
connections
[
0
],
connections
[
1
],
properties
[
'value'
],
name
);
else
if
(
type
==
'o'
)
// op amp
else
if
(
type
==
'o'
)
// op amp
this
.
opamp
(
connections
[
0
],
connections
[
1
],
connections
[
2
],
properties
[
'A'
],
name
);
this
.
opamp
(
connections
[
0
],
connections
[
1
],
connections
[
2
],
connections
[
3
],
properties
[
'A'
],
name
);
else
if
(
type
==
'n'
)
// n fet
else
if
(
type
==
'n'
)
// n fet
this
.
n
(
connections
[
0
],
connections
[
1
],
connections
[
2
],
properties
[
'W/L'
],
name
);
this
.
n
(
connections
[
0
],
connections
[
1
],
connections
[
2
],
properties
[
'W/L'
],
name
);
else
if
(
type
==
'p'
)
// p fet
else
if
(
type
==
'p'
)
// p fet
this
.
p
(
connections
[
0
],
connections
[
1
],
connections
[
2
],
properties
[
'W/L'
],
name
);
this
.
p
(
connections
[
0
],
connections
[
1
],
connections
[
2
],
properties
[
'W/L'
],
name
);
}
}
if
(
!
found_ground
)
{
// No ground on schematic
alert
(
'Please make at least one connection to ground (inverted T symbol)'
);
return
false
;
}
return
true
;
}
}
// if converges: updates this.solution, this.soln_max, returns iter count
// if converges: updates this.solution, this.soln_max, returns iter count
...
@@ -187,6 +203,8 @@ cktsim = (function() {
...
@@ -187,6 +203,8 @@ cktsim = (function() {
// DC analysis
// DC analysis
Circuit
.
prototype
.
dc
=
function
()
{
Circuit
.
prototype
.
dc
=
function
()
{
// Allocation matrices for linear part, etc.
this
.
finalize
();
this
.
finalize
();
// Load up the linear part.
// Load up the linear part.
...
@@ -624,6 +642,17 @@ cktsim = (function() {
...
@@ -624,6 +642,17 @@ cktsim = (function() {
return
this
.
add_device
(
d
,
name
);
return
this
.
add_device
(
d
,
name
);
}
}
Circuit
.
prototype
.
opamp
=
function
(
np
,
nn
,
no
,
ng
,
A
,
name
)
{
// try to convert string value into numeric value, barf if we can't
if
((
typeof
A
)
==
'string'
)
{
ratio
=
parse_number
(
A
,
undefined
);
if
(
A
===
undefined
)
return
undefined
;
}
var
branch
=
this
.
node
(
undefined
,
T_CURRENT
);
var
d
=
new
Opamp
(
np
,
nn
,
no
,
ng
,
branch
,
A
,
name
);
return
this
.
add_device
(
d
,
name
);
}
Circuit
.
prototype
.
n
=
function
(
d
,
g
,
s
,
ratio
,
name
)
{
Circuit
.
prototype
.
n
=
function
(
d
,
g
,
s
,
ratio
,
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
ratio
)
==
'string'
)
{
if
((
typeof
ratio
)
==
'string'
)
{
...
@@ -1090,6 +1119,15 @@ cktsim = (function() {
...
@@ -1090,6 +1119,15 @@ cktsim = (function() {
src
.
value
=
function
(
t
)
{
return
v
;
}
// closure
src
.
value
=
function
(
t
)
{
return
v
;
}
// closure
}
}
// post-processing for impulse sources
// impulse(height,width)
else
if
(
src
.
fun
==
'impulse'
)
{
var
h
=
arg_value
(
src
.
args
,
0
,
1
);
// default height: 1
var
w
=
Math
.
abs
(
arg_value
(
src
.
args
,
2
,
1
e
-
9
));
// default width: 1ns
src
.
args
=
[
h
,
w
];
// remember any defaulted values
pwl_source
(
src
,[
0
,
0
,
w
/
2
,
h
,
w
,
0
],
false
);
}
// post-processing for step sources
// post-processing for step sources
// step(v_init,v_plateau,t_delay,t_rise)
// step(v_init,v_plateau,t_delay,t_rise)
else
if
(
src
.
fun
==
'step'
)
{
else
if
(
src
.
fun
==
'step'
)
{
...
@@ -1263,8 +1301,8 @@ cktsim = (function() {
...
@@ -1263,8 +1301,8 @@ cktsim = (function() {
// MNA stamp for independent voltage source
// MNA stamp for independent voltage source
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
npos
,
1.0
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
npos
,
1.0
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
nneg
,
-
1.0
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
nneg
,
-
1.0
);
ckt
.
add_to_Gl
(
this
.
npos
,
this
.
branch
,
1.0
);
ckt
.
add_to_Gl
(
this
.
npos
,
this
.
branch
,
-
1.0
);
ckt
.
add_to_Gl
(
this
.
nneg
,
this
.
branch
,
-
1.0
);
ckt
.
add_to_Gl
(
this
.
nneg
,
this
.
branch
,
1.0
);
}
}
// Source voltage added to b.
// Source voltage added to b.
...
@@ -1448,9 +1486,9 @@ cktsim = (function() {
...
@@ -1448,9 +1486,9 @@ cktsim = (function() {
// MNA stamp for inductor linear part
// MNA stamp for inductor linear part
// L on diag of C because L di/dt = v(n1) - v(n2)
// L on diag of C because L di/dt = v(n1) - v(n2)
ckt
.
add_to_Gl
(
this
.
n1
,
this
.
branch
,
1
);
ckt
.
add_to_Gl
(
this
.
n1
,
this
.
branch
,
1
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
n1
,
1
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
n1
,
-
1
);
ckt
.
add_to_Gl
(
this
.
n2
,
this
.
branch
,
-
1
);
ckt
.
add_to_Gl
(
this
.
n2
,
this
.
branch
,
-
1
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
n2
,
-
1
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
n2
,
1
);
ckt
.
add_to_C
(
this
.
branch
,
this
.
branch
,
this
.
value
)
ckt
.
add_to_C
(
this
.
branch
,
this
.
branch
,
this
.
value
)
}
}
...
@@ -1464,6 +1502,51 @@ cktsim = (function() {
...
@@ -1464,6 +1502,51 @@ cktsim = (function() {
Inductor
.
prototype
.
load_tran
=
function
(
ckt
)
{
Inductor
.
prototype
.
load_tran
=
function
(
ckt
)
{
}
}
///////////////////////////////////////////////////////////////////////////////
//
// Simple Voltage-Controlled Voltage Source Op Amp model
//
///////////////////////////////////////////////////////////////////////////////
function
Opamp
(
np
,
nn
,
no
,
ng
,
branch
,
A
,
name
)
{
Device
.
call
(
this
);
this
.
np
=
np
;
this
.
nn
=
nn
;
this
.
no
=
no
;
this
.
ng
=
ng
;
this
.
branch
=
branch
;
this
.
gain
=
A
;
this
.
name
=
name
;
}
Opamp
.
prototype
=
new
Device
();
Opamp
.
prototype
.
constructor
=
Opamp
;
Opamp
.
prototype
.
load_linear
=
function
(
ckt
)
{
// MNA stamp for VCVS: 1/A(v(no) - v(ng)) - (v(np)-v(nn))) = 0.
var
invA
=
1.0
/
this
.
gain
;
ckt
.
add_to_Gl
(
this
.
no
,
this
.
branch
,
1
);
ckt
.
add_to_Gl
(
this
.
ng
,
this
.
branch
,
-
1
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
no
,
-
invA
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
ng
,
invA
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
np
,
1
);
ckt
.
add_to_Gl
(
this
.
branch
,
this
.
nn
,
-
1
);
}
Opamp
.
prototype
.
load_dc
=
function
(
ckt
,
soln
,
rhs
)
{
// Op-amp is linear.
}
Opamp
.
prototype
.
load_ac
=
function
(
ckt
)
{
}
Opamp
.
prototype
.
load_tran
=
function
(
ckt
)
{
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
//
// Simplified MOS FET with no bulk connection and no body effect.
// Simplified MOS FET with no bulk connection and no body effect.
...
...
js/schematic.js
View file @
ae3ed270
...
@@ -113,7 +113,7 @@ schematic = (function() {
...
@@ -113,7 +113,7 @@ schematic = (function() {
// else just populate parts bin with all the parts
// else just populate parts bin with all the parts
this
.
edits_allowed
=
true
;
this
.
edits_allowed
=
true
;
var
parts
=
input
.
getAttribute
(
'parts'
);
var
parts
=
input
.
getAttribute
(
'parts'
);
if
(
parts
==
undefined
)
{
if
(
parts
==
undefined
||
parts
==
'None'
)
{
parts
=
new
Array
();
parts
=
new
Array
();
for
(
var
p
in
parts_map
)
parts
.
push
(
p
);
for
(
var
p
in
parts_map
)
parts
.
push
(
p
);
}
else
if
(
parts
==
''
)
{
}
else
if
(
parts
==
''
)
{
...
@@ -133,7 +133,8 @@ schematic = (function() {
...
@@ -133,7 +133,8 @@ schematic = (function() {
// use user-supplied list of analyses, otherwise provide them all
// use user-supplied list of analyses, otherwise provide them all
// analyses="" means no analyses
// analyses="" means no analyses
var
analyses
=
input
.
getAttribute
(
'analyses'
);
var
analyses
=
input
.
getAttribute
(
'analyses'
);
if
(
analyses
==
undefined
)
analyses
=
[
'dc'
,
'ac'
,
'tran'
];
if
(
analyses
==
undefined
||
analyses
==
'None'
)
analyses
=
[
'dc'
,
'ac'
,
'tran'
];
else
if
(
analyses
==
''
)
analyses
=
[];
else
if
(
analyses
==
''
)
analyses
=
[];
else
analyses
=
analyses
.
split
(
','
);
else
analyses
=
analyses
.
split
(
','
);
...
@@ -193,7 +194,6 @@ schematic = (function() {
...
@@ -193,7 +194,6 @@ schematic = (function() {
this
.
canvas
.
style
.
borderStyle
=
'solid'
;
this
.
canvas
.
style
.
borderStyle
=
'solid'
;
this
.
canvas
.
style
.
borderWidth
=
'1px'
;
this
.
canvas
.
style
.
borderWidth
=
'1px'
;
this
.
canvas
.
style
.
borderColor
=
grid_style
;
this
.
canvas
.
style
.
borderColor
=
grid_style
;
//this.canvas.style.position = 'absolute';
this
.
canvas
.
style
.
outline
=
'none'
;
this
.
canvas
.
style
.
outline
=
'none'
;
}
}
...
@@ -273,6 +273,9 @@ schematic = (function() {
...
@@ -273,6 +273,9 @@ schematic = (function() {
tr
=
document
.
createElement
(
'tr'
);
tr
=
document
.
createElement
(
'tr'
);
table
.
appendChild
(
tr
);
table
.
appendChild
(
tr
);
td
=
document
.
createElement
(
'td'
);
td
=
document
.
createElement
(
'td'
);
td
.
style
.
position
=
'relative'
;
// so we can position subwindows
td
.
style
.
left
=
'0'
;
td
.
style
.
top
=
'0'
;
tr
.
appendChild
(
td
);
tr
.
appendChild
(
td
);
td
.
appendChild
(
this
.
canvas
);
td
.
appendChild
(
this
.
canvas
);
td
=
document
.
createElement
(
'td'
);
td
=
document
.
createElement
(
'td'
);
...
@@ -634,9 +637,10 @@ schematic = (function() {
...
@@ -634,9 +637,10 @@ schematic = (function() {
// create a circuit from the netlist
// create a circuit from the netlist
var
ckt
=
new
cktsim
.
Circuit
();
var
ckt
=
new
cktsim
.
Circuit
();
ckt
.
load_netlist
(
netlist
);
if
(
ckt
.
load_netlist
(
netlist
))
return
ckt
;
return
ckt
;
else
return
null
;
}
}
Schematic
.
prototype
.
dc_analysis
=
function
()
{
Schematic
.
prototype
.
dc_analysis
=
function
()
{
...
@@ -645,6 +649,7 @@ schematic = (function() {
...
@@ -645,6 +649,7 @@ schematic = (function() {
this
.
redraw_background
();
this
.
redraw_background
();
var
ckt
=
this
.
extract_circuit
();
var
ckt
=
this
.
extract_circuit
();
if
(
ckt
===
null
)
return
;
// run the analysis
// run the analysis
this
.
operating_point
=
ckt
.
dc
();
this
.
operating_point
=
ckt
.
dc
();
...
@@ -712,6 +717,7 @@ schematic = (function() {
...
@@ -712,6 +717,7 @@ schematic = (function() {
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
// run the analysis
var
ckt
=
this
.
extract_circuit
();
var
ckt
=
this
.
extract_circuit
();
if
(
ckt
===
null
)
return
;
var
results
=
ckt
.
ac
(
npts
,
fstart
,
fstop
,
ac_source_name
);
var
results
=
ckt
.
ac
(
npts
,
fstart
,
fstop
,
ac_source_name
);
// save a copy of the results for submission
// save a copy of the results for submission
...
@@ -731,11 +737,28 @@ schematic = (function() {
...
@@ -731,11 +737,28 @@ schematic = (function() {
var
y_values
=
[];
// list of [color, result_array]
var
y_values
=
[];
// list of [color, result_array]
var
probes
=
this
.
find_probes
();
var
probes
=
this
.
find_probes
();
var
probe_maxv
=
[];
var
probe_color
=
[];
// Check for proble with near zero transfer function and warn
for
(
var
i
=
probes
.
length
-
1
;
i
>=
0
;
--
i
)
{
for
(
var
i
=
probes
.
length
-
1
;
i
>=
0
;
--
i
)
{
var
color
=
probes
[
i
][
0
];
probe_color
[
i
]
=
probes
[
i
][
0
];
var
label
=
probes
[
i
][
1
];
var
label
=
probes
[
i
][
1
];
var
v
=
results
[
label
];
var
v
=
results
[
label
];
probe_maxv
[
i
]
=
array_max
(
v
);
// magnitudes always > 0
}
var
all_max
=
array_max
(
probe_maxv
);
for
(
var
i
=
probes
.
length
-
1
;
i
>=
0
;
--
i
)
{
if
((
probe_maxv
[
i
]
/
all_max
)
<
1.0
e
-
10
)
{
alert
(
'Near zero ac response, remove '
+
probe_color
[
i
]
+
' probe'
);
return
;
}
}
for
(
var
i
=
probes
.
length
-
1
;
i
>=
0
;
--
i
)
{
var
color
=
probes
[
i
][
0
];
var
label
=
probes
[
i
][
1
];
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
;
for
(
var
j
=
v
.
length
-
1
;
j
>=
0
;
--
j
)
for
(
var
j
=
v
.
length
-
1
;
j
>=
0
;
--
j
)
...
@@ -774,6 +797,8 @@ schematic = (function() {
...
@@ -774,6 +797,8 @@ schematic = (function() {
this
.
dialog
(
'Transient Analysis'
,
content
,
function
(
content
)
{
this
.
dialog
(
'Transient Analysis'
,
content
,
function
(
content
)
{
var
sch
=
content
.
sch
;
var
sch
=
content
.
sch
;
var
ckt
=
sch
.
extract_circuit
();
var
ckt
=
sch
.
extract_circuit
();
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_npts
=
content
.
fields
[
npts_lbl
].
value
;
...
@@ -792,8 +817,8 @@ schematic = (function() {
...
@@ -792,8 +817,8 @@ schematic = (function() {
ckt
.
parse_number
(
sch
.
tran_tstop
),
probe_names
,
false
);
ckt
.
parse_number
(
sch
.
tran_tstop
),
probe_names
,
false
);
// save a copy of the results for submission
// save a copy of the results for submission
this
.
transient_results
=
{};
sch
.
transient_results
=
{};
for
(
var
i
in
results
)
this
.
transient_results
[
i
]
=
results
[
i
];
for
(
var
i
in
results
)
sch
.
transient_results
[
i
]
=
results
[
i
];
if
(
typeof
results
==
'string'
)
if
(
typeof
results
==
'string'
)
sch
.
message
(
results
);
sch
.
message
(
results
);
...
@@ -1210,6 +1235,7 @@ schematic = (function() {
...
@@ -1210,6 +1235,7 @@ schematic = (function() {
// 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
;
}
}
...
@@ -1317,6 +1343,7 @@ schematic = (function() {
...
@@ -1317,6 +1343,7 @@ schematic = (function() {
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
ok_button
.
addEventListener
(
'click'
,
dialog_okay
,
false
);
ok_button
.
addEventListener
(
'click'
,
dialog_okay
,
false
);
ok_button
.
style
.
display
=
'inline'
;
ok_button
.
style
.
border
=
'1px solid'
;
ok_button
.
style
.
border
=
'1px solid'
;
ok_button
.
style
.
padding
=
'5px'
;
ok_button
.
style
.
padding
=
'5px'
;
ok_button
.
style
.
margin
=
'10px'
;
ok_button
.
style
.
margin
=
'10px'
;
...
@@ -1326,6 +1353,7 @@ schematic = (function() {
...
@@ -1326,6 +1353,7 @@ schematic = (function() {
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
cancel_button
.
addEventListener
(
'click'
,
dialog_cancel
,
false
);
cancel_button
.
addEventListener
(
'click'
,
dialog_cancel
,
false
);
cancel_button
.
style
.
display
=
'inline'
;
cancel_button
.
style
.
border
=
'1px solid'
;
cancel_button
.
style
.
border
=
'1px solid'
;
cancel_button
.
style
.
padding
=
'5px'
;
cancel_button
.
style
.
padding
=
'5px'
;
cancel_button
.
style
.
margin
=
'10px'
;
cancel_button
.
style
.
margin
=
'10px'
;
...
@@ -1449,9 +1477,9 @@ schematic = (function() {
...
@@ -1449,9 +1477,9 @@ schematic = (function() {
win
.
appendChild
(
content
);
win
.
appendChild
(
content
);
content
.
win
=
win
;
// so content can contact us
content
.
win
=
win
;
// so content can contact us
// compute location
in top-level div
// compute location
relative to canvas
win
.
left
=
this
.
canvas
.
pag
e_x
;
win
.
left
=
this
.
canvas
.
mous
e_x
;
win
.
top
=
this
.
canvas
.
pag
e_y
;
win
.
top
=
this
.
canvas
.
mous
e_y
;
// add to DOM
// add to DOM
win
.
style
.
background
=
'white'
;
win
.
style
.
background
=
'white'
;
...
@@ -1461,7 +1489,8 @@ schematic = (function() {
...
@@ -1461,7 +1489,8 @@ schematic = (function() {
win
.
style
.
top
=
win
.
top
+
'px'
;
win
.
style
.
top
=
win
.
top
+
'px'
;
win
.
style
.
border
=
'2px solid'
;
win
.
style
.
border
=
'2px solid'
;
this
.
input
.
parentNode
.
insertBefore
(
win
,
this
.
input
.
nextSibling
);
this
.
canvas
.
parentNode
.
insertBefore
(
win
,
this
.
canvas
);
//this.input.parentNode.insertBefore(win,this.input.nextSibling);
}
}
// close the window
// close the window
...
@@ -1606,7 +1635,10 @@ schematic = (function() {
...
@@ -1606,7 +1635,10 @@ schematic = (function() {
if
(
!
event
)
event
=
window
.
event
;
if
(
!
event
)
event
=
window
.
event
;
var
tool
=
(
window
.
event
)
?
event
.
srcElement
:
event
.
target
;
var
tool
=
(
window
.
event
)
?
event
.
srcElement
:
event
.
target
;
if
(
tool
.
enabled
)
tool
.
callback
.
call
(
tool
.
sch
);
if
(
tool
.
enabled
)
{
tool
.
sch
.
canvas
.
relMouseCoords
(
event
);
// so we can position pop-up window correctly
tool
.
callback
.
call
(
tool
.
sch
);
}
}
}
cut_icon
=
'data:image/gif;base64,R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAAcALAAAAAAQABAAAAQu8MhJqz1g5qs7lxv2gRkQfuWomarXEgDRHjJhf3YtyRav0xcfcFgR0nhB5OwTAQA7'
;
cut_icon
=
'data:image/gif;base64,R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAAcALAAAAAAQABAAAAQu8MhJqz1g5qs7lxv2gRkQfuWomarXEgDRHjJhf3YtyRav0xcfcFgR0nhB5OwTAQA7'
;
...
@@ -1943,25 +1975,27 @@ schematic = (function() {
...
@@ -1943,25 +1975,27 @@ schematic = (function() {
var
x1
=
(
index
==
0
)
?
x_values
[
0
]
:
x_values
[
index
-
1
];
var
x1
=
(
index
==
0
)
?
x_values
[
0
]
:
x_values
[
index
-
1
];
var
x2
=
x_values
[
index
];
var
x2
=
x_values
[
index
];
// for each plot, interpolate and output value at intersection with marker
if
(
x2
!=
undefined
)
{
c
.
textAlign
=
'left'
;
// for each plot, interpolate and output value at intersection with marker
var
tx
=
graph
.
left_margin
+
4
;
c
.
textAlign
=
'left'
;
var
ty
=
graph
.
top_margin
;
var
tx
=
graph
.
left_margin
+
4
;
for
(
var
plot
=
0
;
plot
<
graph
.
y_values
.
length
;
plot
++
)
{
var
ty
=
graph
.
top_margin
;
var
values
=
graph
.
y_values
[
plot
][
1
];
for
(
var
plot
=
0
;
plot
<
graph
.
y_values
.
length
;
plot
++
)
{
var
values
=
graph
.
y_values
[
plot
][
1
];
// interpolate signal value at graph_x using values[index-1] and values[index]
var
y1
=
(
index
==
0
)
?
values
[
0
]
:
values
[
index
-
1
];
// interpolate signal value at graph_x using values[index-1] and values[index]
var
y2
=
values
[
index
];
var
y1
=
(
index
==
0
)
?
values
[
0
]
:
values
[
index
-
1
];
var
y
=
y1
;
var
y2
=
values
[
index
];
if
(
graph_x
!=
x1
)
y
+=
(
graph_x
-
x1
)
*
(
y2
-
y1
)
/
(
x2
-
x1
);
var
y
=
y1
;
if
(
graph_x
!=
x1
)
y
+=
(
graph_x
-
x1
)
*
(
y2
-
y1
)
/
(
x2
-
x1
);
// annotate plot with value of signal at marker
c
.
fillStyle
=
element_style
;
// annotate plot with value of signal at marker
c
.
fillText
(
'
\
u2588
\
u2588
\
u2588
\
u2588
\
u2588'
,
tx
-
3
,
ty
);
c
.
fillStyle
=
element_style
;
c
.
fillStyle
=
probe_colors_rgb
[
graph
.
y_values
[
plot
][
0
]];
c
.
fillText
(
'
\
u2588
\
u2588
\
u2588
\
u2588
\
u2588'
,
tx
-
3
,
ty
);
c
.
fillText
(
engineering_notation
(
y
,
3
,
false
),
tx
,
ty
);
c
.
fillStyle
=
probe_colors_rgb
[
graph
.
y_values
[
plot
][
0
]];
ty
+=
14
;
c
.
fillText
(
engineering_notation
(
y
,
3
,
false
),
tx
,
ty
);
ty
+=
14
;
}
}
}
}
}
}
}
...
@@ -3086,7 +3120,8 @@ schematic = (function() {
...
@@ -3086,7 +3120,8 @@ schematic = (function() {
this
.
add_connection
(
0
,
0
);
// +
this
.
add_connection
(
0
,
0
);
// +
this
.
add_connection
(
0
,
16
);
// -
this
.
add_connection
(
0
,
16
);
// -
this
.
add_connection
(
48
,
8
);
// output
this
.
add_connection
(
48
,
8
);
// output
this
.
bounding_box
=
[
0
,
-
8
,
48
,
24
];
this
.
add_connection
(
24
,
32
);
// ground
this
.
bounding_box
=
[
0
,
-
8
,
48
,
32
];
this
.
update_coords
();
this
.
update_coords
();
}
}
OpAmp
.
prototype
=
new
Component
();
OpAmp
.
prototype
=
new
Component
();
...
@@ -3104,7 +3139,9 @@ schematic = (function() {
...
@@ -3104,7 +3139,9 @@ schematic = (function() {
// inputs and output
// inputs and output
this
.
draw_line
(
c
,
0
,
0
,
8
,
0
);
this
.
draw_line
(
c
,
0
,
0
,
8
,
0
);
this
.
draw_line
(
c
,
0
,
16
,
8
,
16
);
this
.
draw_line
(
c
,
0
,
16
,
8
,
16
);
this
.
draw_text
(
c
,
'gnd'
,
37
,
18
,
property_size
);
this
.
draw_line
(
c
,
40
,
8
,
48
,
8
);
this
.
draw_line
(
c
,
40
,
8
,
48
,
8
);
this
.
draw_line
(
c
,
24
,
16
,
24
,
32
);
// + and -
// + and -
this
.
draw_line
(
c
,
10
,
0
,
16
,
0
);
this
.
draw_line
(
c
,
10
,
0
,
16
,
0
);
this
.
draw_line
(
c
,
13
,
-
3
,
13
,
3
);
this
.
draw_line
(
c
,
13
,
-
3
,
13
,
3
);
...
@@ -3176,6 +3213,9 @@ schematic = (function() {
...
@@ -3176,6 +3213,9 @@ schematic = (function() {
source_functions
=
{
source_functions
=
{
'dc'
:
[
'DC value'
],
'dc'
:
[
'DC value'
],
'impulse'
:
[
'Height'
,
'Width (secs)'
],
'step'
:
[
'Initial value'
,
'step'
:
[
'Initial value'
,
'Plateau value'
,
'Plateau value'
,
'Delay until step (secs)'
,
'Delay until step (secs)'
,
...
...
js/video_player.js
View file @
ae3ed270
...
@@ -48,6 +48,17 @@ function postJSON(url, data, callback) {
...
@@ -48,6 +48,17 @@ function postJSON(url, data, callback) {
});
});
}
}
function
postJSONAsync
(
url
,
data
,
callback
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
url
,
dataType
:
'json'
,
data
:
data
,
success
:
callback
,
headers
:
{
'X-CSRFToken'
:
getCookie
(
'csrftoken'
)},
async
:
true
});
}
// For easy embedding of CSRF in forms
// For easy embedding of CSRF in forms
$
(
function
()
{
$
(
function
()
{
$
(
'#csrfmiddlewaretoken'
).
attr
(
"value"
,
getCookie
(
'csrftoken'
))
$
(
'#csrfmiddlewaretoken'
).
attr
(
"value"
,
getCookie
(
'csrftoken'
))
...
@@ -212,7 +223,10 @@ function onPlayerStateChange(event) {
...
@@ -212,7 +223,10 @@ function onPlayerStateChange(event) {
var
switched_tab
=
false
;
// switch to true when we destroy so we know to call onYouTubePlayerAPIReady()
var
switched_tab
=
false
;
// switch to true when we destroy so we know to call onYouTubePlayerAPIReady()
// clear pings to video status when we switch to a different sequence tab with ajax
// clear pings to video status when we switch to a different sequence tab with ajax
function
videoDestroy
()
{
function
videoDestroy
(
id
)
{
// postJSON('/modx/video/'+id+'/goto_position',
// {'position' : ytplayer.getCurrentTime()});
load_id
=
0
;
load_id
=
0
;
clearInterval
(
updateytplayerInfoInterval
);
clearInterval
(
updateytplayerInfoInterval
);
clearInterval
(
ajax_videoInterval
);
clearInterval
(
ajax_videoInterval
);
...
@@ -283,7 +297,7 @@ function onytplayerStateChange(newState) {
...
@@ -283,7 +297,7 @@ function onytplayerStateChange(newState) {
}
}
function
onPlayerError
(
errorCode
)
{
function
onPlayerError
(
errorCode
)
{
alert
(
"An error occured: "
+
errorCode
);
//
alert("An error occured: " + errorCode);
}
}
function
updateytplayerInfo
()
{
function
updateytplayerInfo
()
{
...
@@ -318,6 +332,8 @@ function loadNewVideo(id, startSeconds) {
...
@@ -318,6 +332,8 @@ function loadNewVideo(id, startSeconds) {
catch
(
e
)
{
catch
(
e
)
{
window
[
'console'
].
log
(
JSON
.
stringify
(
e
));
window
[
'console'
].
log
(
JSON
.
stringify
(
e
));
}
}
//$("#slider").slider("option","value",startSeconds);
//seekTo(startSeconds);
}
}
function
cueNewVideo
(
id
,
startSeconds
)
{
function
cueNewVideo
(
id
,
startSeconds
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment