forked from kazuhikoarase/simcirjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.html
246 lines (233 loc) · 7.11 KB
/
sample.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<script type="text/javascript" src="jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="simcir.js"></script>
<link rel="stylesheet" type="text/css" href="simcir.css" />
<script type="text/javascript" src="simcir-basicset.js"></script>
<link rel="stylesheet" type="text/css" href="simcir-basicset.css" />
<script type="text/javascript" src="simcir-library.js"></script>
<style type="text/css">
* {
font-family: arial, sans-serif;
}
.code {
margin: 16px 0px 16px 0px;
padding: 4px;
border-width: 0px 0px 0px 4px;
border-color: #cccccc;
border-style: solid;
background-color: #f0f0f0;
white-space: pre;
}
.note {
color: #0000ff;
}
</style>
<title>SimcirJS</title>
</head>
<body>
<h1>SimcirJS</h1>
<div style="margin:16px 0px 16px 0px">
SimcirJS(a.k.a. Simcir) is a circuit simulator in HTML5 and JavaScript.
<br/>
Let's try your circuit!
</div>
<h2>Usage</h2>
<ul>
<li>Choose a device from the toolbox and move to right side.</li>
<li>Connect them by drag operation.</li>
<li>Click an input node to disconnect.</li>
<li>Move a device back to the toolbox if you don't use.</li>
<li>Ctrl+Click(Mac:command+Click) to toggle view (Live circuit or JSON data).</li>
<li>Double-Click a label to edit device name.</li>
<li>Double-Click a library to open the circuit inside.</li>
</ul>
<!--
Specify width and height only.
All the other attributes will be used defaults.
-->
<div class="simcir">
{
"width":800,
"height":400
}
</div>
<h2>Embed your circuit</h2>
<p>
Ctrl+Click(Mac:command+Click) on your circuit and copy a circuit data.
<br/>
Then paste it into template below.
</p>
<div class="code"
><!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<script type="text/javascript" src="jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="simcir.js"></script>
<link rel="stylesheet" type="text/css" href="simcir.css" />
<script type="text/javascript" src="simcir-basicset.js"></script>
<link rel="stylesheet" type="text/css" href="simcir-basicset.css" />
<script type="text/javascript" src="simcir-library.js"></script>
<title></title>
</head>
<body>
<div class="simcir">
<span class="note"><!-- paste here your circuit data --></span>
</div>
</body>
</html>
</div>
<h2>Reuse your circuit</h2>
<p>
To reuse your circuit as library, use device 'In' and 'Out'.
</p>
<div class="simcir">
{
"width":500,
"height":200,
"showToolbox":true,
"toolbox":[
{"type":"In"},
{"type":"Out"},
{"type":"DC"},
{"type":"PushOff"},
{"type":"PushOn"},
{"type":"Toggle"},
{"type":"NAND"}
],
"devices":[
{"type":"DC","id":"dev0","x":64,"y":80,"label":"DC"},
{"type":"PushOff","id":"dev1","x":120,"y":48,"label":"PushOff"},
{"type":"PushOff","id":"dev2","x":120,"y":112,"label":"PushOff"},
{"type":"In","id":"dev3","x":176,"y":48,"label":"~S"},
{"type":"In","id":"dev4","x":176,"y":112,"label":"~R"},
{"type":"NAND","id":"dev5","x":232,"y":56,"label":"NAND"},
{"type":"NAND","id":"dev6","x":232,"y":104,"label":"NAND"},
{"type":"Out","id":"dev7","x":288,"y":56,"label":"Q"},
{"type":"Out","id":"dev8","x":288,"y":104,"label":"~Q"}
],
"connectors":[
{"from":"dev1.in0","to":"dev0.out0"},
{"from":"dev2.in0","to":"dev0.out0"},
{"from":"dev3.in0","to":"dev1.out0"},
{"from":"dev4.in0","to":"dev2.out0"},
{"from":"dev5.in0","to":"dev3.out0"},
{"from":"dev5.in1","to":"dev6.out0"},
{"from":"dev6.in0","to":"dev5.out0"},
{"from":"dev6.in1","to":"dev4.out0"},
{"from":"dev7.in0","to":"dev5.out0"},
{"from":"dev8.in0","to":"dev6.out0"}
]
}
</div>
<p>
Then register it in JavaScript and add to the toolbox in HTML.
</p>
<div class="code"
>simcir.registerDevice('<span class="note">MyDevice</span>',
<span class="note">// paste here your circuit data</span>
);
</div>
<div class="code"
><div class="simcir">
⋮
"toolbox":[
{"type":"DC"},
{"type":"PushOff"},
⋮
{"type":"<span class="note">MyDevice</span>"}
],
⋮
</div>
</div>
<p>
In this case, a new device 'RS-FF' is added.
Try to Double-Click the 'RS-FF' :)
<br/>
Remember that all the connectors on
an input of 'In' and an output of 'Out'
are disconnected internally when the device is reused.
</p>
<div class="simcir">
{
"width":500,
"height":200,
"showToolbox":true,
"toolbox":[
{"type":"DC"},
{"type":"PushOff"},
{"type":"RS-FF"}
],
"devices":[
{"type":"DC","id":"dev0","x":104,"y":80,"label":"DC"},
{"type":"PushOff","id":"dev1","x":160,"y":48,"label":"PushOff"},
{"type":"PushOff","id":"dev2","x":160,"y":112,"label":"PushOff"},
{"type":"RS-FF","id":"dev3","x":216,"y":80,"label":"RS-FF"}
],
"connectors":[
{"from":"dev1.in0","to":"dev0.out0"},
{"from":"dev2.in0","to":"dev0.out0"},
{"from":"dev3.in0","to":"dev1.out0"},
{"from":"dev3.in1","to":"dev2.out0"}
]
}
</div>
<h2>Customize a device</h2>
<p>
label, color, number of inputs, freq ...
</p>
<div class="simcir">
{
"width":500,
"height":400,
"showToolbox":true,
"toolbox":[
{"type":"DC"},
{"type":"Toggle"},
{"type":"LED","color":"#00ff00","label":"LED(G)"},
{"type":"NAND","numInputs":"3","label":"NAND(3in)"},
{"type":"OSC","freq":1,"label":"OSC(1Hz)"},
{"type":"7seg","color":"#000000","bgColor":"#889988"}
],
"devices":[
{"type":"NAND","numInputs":"3","label":"NAND(3in)","id":"dev0","x":208,"y":128},
{"type":"Toggle","id":"dev1","x":152,"y":80,"label":"Toggle"},
{"type":"Toggle","id":"dev2","x":152,"y":128,"label":"Toggle"},
{"type":"Toggle","id":"dev3","x":152,"y":176,"label":"Toggle"},
{"type":"DC","id":"dev4","x":96,"y":128,"label":"DC"},
{"type":"LED","color":"#00ff00","label":"LED(G)","id":"dev5","x":264,"y":128},
{"type":"OSC","freq":1,"label":"OSC(1Hz)","id":"dev6","x":96,"y":232},
{"type":"NAND","numInputs":"3","label":"NAND(3in)","id":"dev7","x":152,"y":272},
{"type":"7seg","color":"#000000","bgColor":"#889988","id":"dev8","x":208,"y":232,"label":"7seg"}
],
"connectors":[
{"from":"dev0.in0","to":"dev1.out0"},
{"from":"dev0.in1","to":"dev2.out0"},
{"from":"dev0.in2","to":"dev3.out0"},
{"from":"dev1.in0","to":"dev4.out0"},
{"from":"dev2.in0","to":"dev4.out0"},
{"from":"dev3.in0","to":"dev4.out0"},
{"from":"dev5.in0","to":"dev0.out0"},
{"from":"dev7.in0","to":"dev6.out0"},
{"from":"dev7.in1","to":"dev6.out0"},
{"from":"dev7.in2","to":"dev6.out0"},
{"from":"dev8.in0","to":"dev6.out0"},
{"from":"dev8.in1","to":"dev7.out0"},
{"from":"dev8.in2","to":"dev7.out0"},
{"from":"dev8.in3","to":"dev6.out0"},
{"from":"dev8.in4","to":"dev7.out0"},
{"from":"dev8.in5","to":"dev7.out0"},
{"from":"dev8.in6","to":"dev6.out0"}
]
}
</div>
<div class="simcir-doc"></div>
<hr/>
<div style="text-align: right;">
Contents Copyright © Kazuhiko Arase
</div>
</body>
</html>