How data is generated for saving a project?
Contributing author: @shubhankarsharma00
When saving a project the first function called is..... (yeah you guessed it) save()
. This function calls generateData()
to generate serialized JSON and then the JSON is sent onto /simulator/update_data.
generateData()
gathers all information on the project, different properties of a project added onto the serialized JSON for saving it are:
- name: name of the project
- timePeriod: time period after which
clockTick
function is called. - clockEnabled: If the clock is enabled or not
- projectId: A unique random alphanumeric string
- focussedCircuit: the current circuit in focus
- scopes: After this, an array of scopes begin and have the following info:
- layout: This defines how the SubCircuit for a circuit will look if included in some other file and can be modified in layout mode.
- allNodes: This is an array of Nodes. Has x, y, type, bitwidth, label, and an array of connections.
- id: Id of the circuit
- name: name of the circuit.
- An array of all the elements included with the name of the element as key for it. For eg: data["NotGate"] will have an array of all not gates as a NotGate object. This is where SubCircuits are included too as they are also CircuitElements.
- nodes: An array of intermediatory node Id's.
When the scopes data is serialized, dependencies for each scope is gathered and JSON data generated by a call to backUp()
this function basically removes all subcircuit connection made on a circuit (to avoid duplicating a scope) and then saves the id's of nodes and their connections. Also, information on all modules is serialized calling saveObject()
which is a member function for all the CircuitElement class objects. (backUp()
Also makes all the subcircuit connections it removed after generating the JSON).
More information on how a Circuit Element is stored:
- saveObject defines all these keys for data
x: this.x, y: this.y, objectType: this.objectType, label: this.label, direction: this.direction, labelDirection: this.labelDirection, propagationDelay: this.propagationDelay, customData: this.customSave()
- To get customData .customSave() call is made which serializes the data related to the parameters to be passed and all the nodes connected to an element.
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