Skip to content

How data is generated for saving a project?

Shubhankar Sharma edited this page May 17, 2020 · 3 revisions

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:

  1. name: name of the project
  2. timePeriod: time period after which clockTick function is called.
  3. clockEnabled: If the clock is enabled or not
  4. projectId: A unique random alphanumeric string
  5. focussedCircuit: the current circuit in focus
  6. scopes: After this, an array of scopes begin and have the following info:
    1. layout: This defines how the SubCircuit for a circuit will look if included in some other file and can be modified in layout mode.
    2. allNodes: This is an array of Nodes. Has x, y, type, bitwidth, label, and an array of connections.
    3. id: Id of the circuit
    4. name: name of the circuit.
    5. 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.
  7. 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:

  1. 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()
  2. 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.
Clone this wiki locally