Skip to content

Commit 8c0907a

Browse files
committed
Добавлена страница симулятора логических схем
1 parent e1518ef commit 8c0907a

File tree

7 files changed

+996
-19
lines changed

7 files changed

+996
-19
lines changed

public/build/assets/simulator-BlfGN52r.js

-3
This file was deleted.

public/build/assets/simulator-OoWcS2fe.js

+420
Large diffs are not rendered by default.

public/build/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
"src": "resources/images/simulator/hand.png"
259259
},
260260
"resources/images/simulator/openhand.svg": {
261-
"file": "assets/openhand-BqKsOpwG.svg",
261+
"file": "assets/openhand-DWQ41LG6.svg",
262262
"src": "resources/images/simulator/openhand.svg"
263263
},
264264
"resources/images/simulator/pencil.svg": {
@@ -314,7 +314,7 @@
314314
"isEntry": true
315315
},
316316
"resources/js/simulator/simulator.js": {
317-
"file": "assets/simulator-BlfGN52r.js",
317+
"file": "assets/simulator-OoWcS2fe.js",
318318
"name": "simulator",
319319
"src": "resources/js/simulator/simulator.js",
320320
"isEntry": true,

resources/js/simulator/FileManager.js

+146
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,152 @@ export class FileManager {
4444
console.log(eventHistory);*/
4545
}
4646

47+
loadString(content) {
48+
this.isLoadingState = true;
49+
50+
flipflop.splice(0, flipflop.length);
51+
srLatch.splice(0, srLatch.length);
52+
gate.splice(0, gate.length);
53+
wireMng.wire.splice(0, wireMng.wire.length);
54+
logicClock.splice(0, logicClock.length);
55+
logicInput.splice(0, logicInput.length);
56+
logicOutput.splice(0, logicOutput.length);
57+
nodeList.splice(0, nodeList.length);
58+
59+
let contentFile = content;
60+
//console.log(contentFile);
61+
62+
// logic input
63+
if ('logicInput' in JSON.parse(contentFile)) {
64+
for (let i = 0; i < contentFile.length; i++) {
65+
let objectParsed = JSON.parse(contentFile).logicInput[i];
66+
67+
if (objectParsed == undefined) break;
68+
69+
console.log(objectParsed);
70+
logicInput.push(new LogicInput());
71+
Object.assign(logicInput[i], objectParsed);
72+
logicInput[i].refreshNodes();
73+
}
74+
}
75+
// logic output
76+
//console.log(logicOutput);
77+
if ('logicOutput' in JSON.parse(contentFile)) {
78+
for (let i = 0; i < contentFile.length; i++) {
79+
let objectParsed = JSON.parse(contentFile).logicOutput[i];
80+
81+
if (objectParsed == undefined) break;
82+
83+
console.log(objectParsed);
84+
logicOutput.push(new LogicOutput());
85+
Object.assign(logicOutput[i], objectParsed);
86+
logicOutput[i].refreshNodes();
87+
}
88+
}
89+
90+
if ('logicClock' in JSON.parse(contentFile)) {
91+
for (let i = 0; i < contentFile.length; i++) {
92+
let objectParsed = JSON.parse(contentFile).logicClock[i];
93+
94+
if (objectParsed == undefined) break;
95+
96+
console.log(objectParsed);
97+
logicClock.push(new Clock());
98+
Object.assign(logicClock[i], objectParsed);
99+
logicClock[i].refreshNodes();
100+
}
101+
}
102+
103+
if ('gate' in JSON.parse(contentFile)) {
104+
for (let i = 0; i < contentFile.length; i++) {
105+
let objectParsed = JSON.parse(contentFile).gate[i];
106+
107+
if (objectParsed == undefined) break;
108+
109+
console.log(objectParsed);
110+
gate.push(new Gate(JSON.parse(contentFile).gate[i].strType));
111+
Object.assign(gate[i], objectParsed);
112+
gate[i].refreshNodes();
113+
}
114+
}
115+
116+
if ('srLatch' in JSON.parse(contentFile)) {
117+
for (let i = 0; i < contentFile.length; i++) {
118+
let objectParsed = JSON.parse(contentFile).srLatch[i];
119+
120+
if (objectParsed == undefined) break;
121+
122+
console.log(objectParsed);
123+
124+
switch (JSON.parse(contentFile).srLatch[i].type) {
125+
case IC_type.SR_LATCH_ASYNC:
126+
srLatch.push(
127+
new SR_LatchAsync(
128+
JSON.parse(contentFile).srLatch[i].gateType,
129+
JSON.parse(contentFile).srLatch[i].stabilize,
130+
),
131+
);
132+
break;
133+
case IC_type.SR_LATCH_SYNC:
134+
srLatch.push(
135+
new SR_LatchSync(
136+
JSON.parse(contentFile).srLatch[i].gateType,
137+
JSON.parse(contentFile).srLatch[i].stabilize,
138+
),
139+
);
140+
break;
141+
}
142+
Object.assign(srLatch[i], objectParsed);
143+
srLatch[i].refreshNodes();
144+
}
145+
}
146+
147+
if ('flipflop' in JSON.parse(contentFile)) {
148+
for (let i = 0; i < contentFile.length; i++) {
149+
let objectParsed = JSON.parse(contentFile).flipflop[i];
150+
151+
if (objectParsed == undefined) break;
152+
153+
console.log(objectParsed);
154+
155+
switch (JSON.parse(contentFile).flipflop[i].type) {
156+
case IC_type.FF_D_SINGLE:
157+
flipflop.push(
158+
new FF_D_Single(JSON.parse(contentFile).flipflop[i].type),
159+
);
160+
break;
161+
case IC_type.FF_D_MASTERSLAVE:
162+
flipflop.push(
163+
new FF_D_MasterSlave(JSON.parse(contentFile).flipflop[i].type),
164+
);
165+
break;
166+
case IC_type.FF_T:
167+
flipflop.push(new FF_T(JSON.parse(contentFile).flipflop[i].type));
168+
break;
169+
case IC_type.FF_JK:
170+
flipflop.push(new FF_JK(JSON.parse(contentFile).flipflop[i].type));
171+
break;
172+
}
173+
Object.assign(flipflop[i], objectParsed);
174+
flipflop[i].refreshNodes();
175+
}
176+
}
177+
178+
if ('wire' in JSON.parse(contentFile)) {
179+
for (let i = 0; i < contentFile.length; i++) {
180+
let objectParsed = JSON.parse(contentFile).wire[i];
181+
182+
if (objectParsed == undefined) break;
183+
184+
console.log(objectParsed);
185+
186+
wireMng.addNode(nodeList[objectParsed.startID]);
187+
wireMng.addNode(nodeList[objectParsed.endID]);
188+
//Object.assign(gate[i], objectParsed);
189+
}
190+
}
191+
}
192+
47193
/**
48194
* @todo TODO
49195
*/

0 commit comments

Comments
 (0)