Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions simulator/src/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import { changeClockEnable } from './sequential';
import { changeInputSize } from './modules';
import { verilogModeGet, verilogModeSet } from './Verilog2CV';
import { updateTestbenchUI } from './testbench';
import load, { removeBugNodes } from './data/load';
import redo from './data/redo';
import undo from './data/undo';

export const circuitProperty = {
toggleLayoutMode, setProjectName, changeCircuitName, changeClockTime, deleteCurrentCircuit, changeClockEnable, changeInputSize, changeLightMode,
Expand Down Expand Up @@ -374,4 +377,26 @@ export default class Scope {
this.ox = (-minX) * this.scale + (width - (maxX - minX) * this.scale) / 2;
this.oy = (-minY) * this.scale + (height - ytoolbarOffset - (maxY - minY) * this.scale) / 2;
}

loadCircuit(data) {
if(data) {
load(data);
}
else{
alert("Invalid data");
}
}

removeBug() {
removeBugNodes(globalScope);
}

next() {
redo(globalScope);
}

previous() {
undo(globalScope);
}

}
4 changes: 2 additions & 2 deletions simulator/src/data/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ function loadModule(data, scope) {
* for some issues while loading nodes.
* @category data
*/
function removeBugNodes(scope = globalScope) {
export function removeBugNodes(scope = globalScope) {
let x = scope.allNodes.length;
for (let i = 0; i < x; i++) {
if (scope.allNodes[i].type !== 2 && scope.allNodes[i].parent.objectType === 'CircuitElement') { scope.allNodes[i].delete(); }
if (scope.allNodes[i].type === 2 && scope.allNodes[i].parent.objectType === 'CircuitElement') { scope.allNodes[i].delete(); }
if (scope.allNodes.length !== x) {
i = 0;
x = scope.allNodes.length;
Expand Down
2 changes: 1 addition & 1 deletion simulator/src/data/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function generateSaveData(name, setName = true) {
data.projectId = projectId;
data.focussedCircuit = globalScope.id;
data.orderedTabs = getTabsOrder();

// Project Circuits, each scope is one circuit
data.scopes = [];
const dependencyList = {};
Expand Down