How Data is loaded in Simulator?
Contributing author: @shubhankarsharma00
When someone tries to open a previouslt saved project or recover some project that was not saved it is done using load()
function. serialized JSON is passed onto the function as a parameter. The function first sets identifying features such as projectId and projectName and then tries to load all the circuits. Since all circuits are stored in a particular order to avoid conflict first all the dependencies of a circuit are loaded by a simple for loop over data.scopes array. These circuits are loaded by calling a function newCircuit(name of the circuit)
and then loading all the serialized data into the new cirucit by using loadScope
function. Inside loadScope we call loadNode
function to make all nodes and then connect them to their connections using constructNodeConnections
. Then we iterate over all modules listed in the JSON data and then we load all the modules (all circuit element except subcircuit) using loadModule
function and load the subcircuits using loadSubciruit
. Next we try to load the layout of a scope's subCircuit and if no data for layout exists we give them default values (This is done because layout wasn't a part of the saved JSON in some old projects). After this a couple of functions from engine.js namely update
and updateRestrictedElementsInScope
are called to update the UI, draw everything and check if any restricted elements are used in the loaded project. After all this the focus is shifted back to the data.focussedCircuit
and updateSimulation, updateCanvas, gridUpdate are set to true and UI update is scheduled using scheduleUpdate function in engine.js.
How loadModules
work?
In loadModules first the constructor of Module is called. data.customData.constructorParamaters is used to pass some of these parameters. Then the properties of the module are updated using data.customData. After all this we iterate over all the nodes of the module and replace new nodes with the correct old nodes (with connections).
loadNode
simply calls Node constructor on Node parameters.
For more information on how loadSubCircuit
, update
and scheduleUpdate
works refer to engine.js and respective wiki pages.
CircuitVerse is a web-based simulation software for creating and testing digital circuits. The easy drag and drop feature makes it easier and a fun way to learn about logic circuits and also compatible to be used by teachers as well as students. From simple gates to complex sequential circuits, plot timing diagrams, automatic circuit generation, explore standard ICs, and much more, CircuitVerse has got you covered. It also lets the user store and access the previously built circuits to build yet more complex circuits and generate truth tables for the constructed circuits.
- Home
- Running the server
- Simulator
- Development
- Internationalization (I18n)
- GSoC '19
- GSoC '20
- GSoC '21
- GSoC '22
- GSoC '23
- GSoC '24
- GCI 2019
- Google Season of Docs 2020