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
20 changes: 19 additions & 1 deletion simulator/src/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import { showProperties } from './ux';
import {
scheduleUpdate, updateSimulationSet,
updateCanvasSet, updateSubcircuitSet,
forceResetNodesSet, changeLightMode,
forceResetNodesSet, changeLightMode, simulationLog, simulation,
// simulationLog, play,
} from './engine';
import { toggleLayoutMode, layoutModeGet } from './layoutMode';
import { setProjectName, getProjectName } from './data/save';
Expand Down Expand Up @@ -374,4 +375,21 @@ 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;
}

getCurrentlySelectedComponent() {
return simulationArea.lastSelected;
}

getAllSelectedComponent() {
return simulationArea.multipleObjectSelections;
}

getSimulationLog() {
return simulationLog();
}

getStepCount() {
return simulation();
}

}
13 changes: 13 additions & 0 deletions simulator/src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ export function updateSelectionsAndPane(scope = globalScope) {
* @param {boolean} resetNodes - boolean to reset all nodes
* @category engine
*/
let simulation_log = [];
let valueue;
export function play(scope = globalScope, resetNodes = false) {
if (errorDetected) return; // Don't simulate until error is fixed
if (loading === true) return; // Don't simulate until loaded
Expand Down Expand Up @@ -403,11 +405,14 @@ export function play(scope = globalScope, resetNodes = false) {
elem.resolve();
stepCount++;
if (stepCount > 1000000) { // Cyclic or infinite Circuit Detection
simulation_log.push(elem);
showError('Simulation Stack limit exceeded: maybe due to cyclic paths or contention');
errorDetectedSet(true);
forceResetNodesSet(true);
}
}
valueue = stepCount;

// Check for TriState Contentions
if (simulationArea.contentionPending.length) {
showError('Contention at TriState');
Expand All @@ -416,6 +421,14 @@ export function play(scope = globalScope, resetNodes = false) {
}
}

export function simulationLog() {
return simulation_log;
}

export function simulation() {
return valueue;
}

/**
* Function to check for any UI update, it is throttled by time
* @param {number=} count - this is used to force update
Expand Down