diff --git a/simulator/src/circuit.js b/simulator/src/circuit.js index 9bd00c6bfe..c517f35fae 100755 --- a/simulator/src/circuit.js +++ b/simulator/src/circuit.js @@ -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'; @@ -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(); + } + } diff --git a/simulator/src/engine.js b/simulator/src/engine.js index d6ae7c689f..9a4602c69f 100755 --- a/simulator/src/engine.js +++ b/simulator/src/engine.js @@ -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 @@ -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'); @@ -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