Members
# constant addKeys
Function used to add or change keys user or default
grabs the keycombo from localstorage &
calls the addShortcut function in a loop to bind them
# constant buttonListenerFunctions
Defines all the functions called as event listeners for buttons on the UI
Object
# canvasMessageData
details of where and what canvas message has to be shown.
Properties:
Name | Type | Description |
---|---|---|
x |
number
|
x cordinate of message |
y |
number
|
x cordinate of message |
string |
number
|
the message |
# constant checkUpdate
Function used to check if new keys are added, adds missing keys if added
# colors
Common canvas theme color object, used for rendering canvas elements
# constant CustomColorThemes
Create Custom Color Themes Dialog
# customTheme
# constant defaultKeys
Add more elements here, along with a valid value for key
Elements keys must have the same name as their ID
# frameInterval
Spec Constants
Size Spec Diagram - https://app.diagrams.net/#G1HFoesRvNyDap95sNJswTy3nH09emDriC
NOTE: Since DPR is set on page load, changing of screen in runtime will not work well
- To Do:
-
- - Support for color themes - Replace constants with functions? - Can support Zoom in and Zoom out of canvas then
# layoutMode
Layout.js - all subcircuit layout related code is here
You can edit how your subcircuit for a circuit will look by
clicking edit layout in properties for a ciruit
Object
# miniMapArea
miniMapAreaThis object is used to draw the miniMap.
Properties:
Name | Type | Description |
---|---|---|
pageY |
number
|
|
pageX |
number
|
|
canvas |
HTMLCanvasObject
|
the canvas object |
setup |
function
|
used to setup the parameters and dimensions |
play |
function
|
used to draw outline of minimap and call resolve |
resolve |
function
|
used to resolve all objects and draw them on minimap |
clear |
function
|
used to clear minimap |
boolean
# objectSelection
true if we have an element selected and
is used when we are paning the grid.
# constant override
fn to override key of duplicate entries
old entry will be left blank & keys will be assigned to the new target
# constant setDefault
Function used to set defaultKeys, grabs the keycombo from the defaultkeys metadata
sets it to the localStorage & cals addKeys
removes the userkeys from localStorage if present
also checks for OS type
# constant setUserKeys
Function used to set userKeys, grabs the keycombo from the panel UI
sets it to the localStorage & cals addKeys
removes the defaultkeys from localStorage
Object
# constant simulationArea
Simulation environment object - holds simulation canvas
Properties:
Name | Type | Description |
---|---|---|
canvas |
HTMLCanvasElement
|
|
selected |
boolean
|
|
hover |
boolean
|
|
clockState |
number
|
|
clockEnabled |
boolean
|
|
lastSelected |
undefined
|
|
stack |
Array
|
|
prevScale |
number
|
|
oldx |
number
|
|
oldy |
number
|
|
objectList |
Array
|
|
maxHeight |
number
|
|
maxWidth |
number
|
|
minHeight |
number
|
|
minWidth |
number
|
|
multipleObjectSelections |
Array
|
|
copyList |
Array
|
List of selected elements |
shiftDown |
boolean
|
shift down or not |
controlDown |
boolean
|
contol down or not |
timePeriod |
number
|
time period |
mouseX |
number
|
mouse x |
mouseY |
number
|
mouse y |
mouseDownX |
number
|
mouse click x |
mouseDownY |
number
|
mouse click y |
simulationQueue |
Array
|
simulation queue |
clickCount |
number
|
number of clicks |
lock |
string
|
locked or unlocked |
timer |
function
|
timer |
setup |
function
|
to setup the simulaton area |
changeClockTime |
function
|
change clock time |
clear |
function
|
clear the simulation area |
# constant updateHTML
fn to update the htokey panel UI with the currently set configuration
# constant warnOverride
function to check if user entered keys are already assigned to other key
gives a warning message if keys already assigned
Methods
# bindIO(data, scopeopt)
Returns object of scope inputs and outputs keyed by their labels
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Object
|
Object containing Test Data | |
scope |
Scope
|
<optional> |
the circuit |
# blockElementPan()
Function BlockElementPan
This function block the pan of elements since in embed simulator you can only view simulator NOT update
# changeCircuitName(name, id)
Used to change name of a circuit
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
new name |
id |
string
|
id of the circuit |
# changeClockEnable()
a global function as a helper for simulationArea.changeClockEnable
# changeLightMode(val)
turn light mode on
Parameters:
Name | Type | Description |
---|---|---|
val |
boolean
|
- new value for light mode |
# checkDistinctIdentifiersData(data)
Checks if all the labels in the test data are unique. Called by validate()
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing Test Data |
# checkDistinctIdentifiersScope(scope)
Checks if all the input/output labels in the scope are unique. Called by validate()
TODO: Replace with identifiers
Parameters:
Name | Type | Description |
---|---|---|
scope |
Scope
|
the circuit |
# checkIfBackup(scope) → {boolean}
Check if backup is available
Parameters:
Name | Type | Description |
---|---|---|
scope |
Scope
|
boolean
# constructNodeConnections(node, data)
Constructs all the connections of Node node
Parameters:
Name | Type | Description |
---|---|---|
node |
Node
|
node to be constructed |
data |
JSON
|
the saved data which is used to load |
# copy(copyList, cutflag)
Helper function for copy
Parameters:
Name | Type | Description |
---|---|---|
copyList |
JSON
|
The data to copied |
cutflag |
boolean
|
flase if we want to copy |
# createBooleanPrompt(inputListNames, outputListNames, scopeopt)
This function hashes the output array and makes required JSON using
a BooleanMinimize class defined in Quin_Mcluskey.js var s which will
be output table is also initialied here
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
inputListNames |
Array
|
labels of input nodes | |
outputListNames |
Array
|
labels of output nodes | |
scope |
Scope
|
<optional> |
h circuit |
# createCombinationalAnalysisPrompt(scopeopt)
The prompt for combinational analysis
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scope |
Scope
|
<optional> |
the circuit in which we want combinational analysis |
# createElements(metadata)
function to generate the specific HTML for the hotkey panel
Parameters:
Name | Type | Description |
---|---|---|
metadata |
object
|
keycombo object |
# createNewCircuitScope()
Wrapper function around newCircuit to be called from + button on UI
# createSubCircuitPrompt(scopeopt)
Prompt to create subcircuit, shows list of circuits which dont depend on the current circuit
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scope |
Scope
|
<optional> |
# creatorOpenPrompt()
UI Function
Create prompt for the testbench UI when creator is opened
# ctx(o)
The mock canvas context
Parameters:
Name | Type | Description |
---|---|---|
o |
options include: ctx - existing Context2D to wrap around width - width of your canvas (defaults to 500) height - height of your canvas (defaults to 500) enableMirroring - enables canvas mirroring (get image data) (defaults to false) document - the document object (defaults to the current document) |
# currentScreen()
Function to return id or class of panel according to screen width
# cut(copyList)
Helper function for cut
Parameters:
Name | Type | Description |
---|---|---|
copyList |
JSON
|
The selected elements |
# decreaseLayoutHeight()
Decrease Height, and move all nodes, check if space is there
# decreaseLayoutWidth()
Decrease Width, and move all nodes, check if space is there
# deleteCurrentCircuit()
Deletes the current circuit
Ensures that at least one circuit is there
Ensures that no circuit depends on the current circuit
Switched to a random circuit
# determineLabel(x, y)
Helper function to determine alignment and position of nodes for rendering
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
width of label |
y |
number
|
height of label |
# downloadAsImg(name, imgType)
Helper function to save canvas as image based on image type
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
name of the circuit |
imgType |
string
|
image type ex: png,jpg etc. |
# dragStart(e, elementId)
Parameters:
Name | Type | Description |
---|---|---|
e |
event
|
|
elementId |
elementId
|
Function to drag element of selected ID |
# embedPanEnd()
Function embedPanEnd
This function update simulator after mouse and touch end
For now variable name starts with mouse like mouseDown are used both
touch and mouse will change in future
# embedPanMove()
Function embedPanMove
This function hepls to move simulator and its elements using touch and mouse
For now variable name starts with mouse like mouseDown are used both
touch and mouse will change in future
# embedPanStart()
Function embedPanStart
This function hepls to initialize mouse and touch
For now variable name starts with mouse like mouseDown are used both
touch and mouse will change in future
# escapeHtml(unsafe)
checkss the input is safe or not
Parameters:
Name | Type | Description |
---|---|---|
unsafe |
HTML
|
the html which we wants to escape |
# extractNode(x, scope, parent)
get Node in index x in scope and set parent
Parameters:
Name | Type | Description |
---|---|---|
x |
Node
|
the desired node |
scope |
Scope
|
the scope |
parent |
CircuitElement
|
The parent of node |
# fillSubcircuitElements()
Fills the elements that can be displayed in the subcircuit, in the subcircuit menu
# forceResetNodesSet(param)
used to set forceResetNodes
Parameters:
Name | Type | Description |
---|---|---|
param |
boolean
|
# generateImage(imgType, view, transparent, resolution, downopt)
Function to generate image for the circuit
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
imgType |
string
|
ex: png,jpg etc. | |
view |
string
|
view type ex: full | |
transparent |
boolean
|
tranparent bg or not | |
resolution |
number
|
resolution of the image | |
down |
boolean
|
<optional> |
will download if true |
# async generateImageForOnline() → {JSON}
Function that is used to save image for display in the website
JSON
# generateSaveData(name) → {JSON}
Generates JSON of the entire project
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
the name of project |
JSON
# getCanvasColors() → {object}
Extracts canvas theme colors from CSS-Variables and returns a JSON Object
object
# getCustomThemeCard()
Generates Custom theme card HTML
return Html Element Theme card html (properties_container)
# getOutputValues(outputs)
Gets Output values as a Map with keys as output name and value as output state
Parameters:
Name | Type | Description |
---|---|---|
outputs |
Object
|
Object with keys as output names and values as outputs |
# getProjectName(name)
Function to set the name of project.
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
name for project |
# getThemeCardSvg(themeName) → {SVG}
Theme Preview Card SVG
Sets the SVG colors according to theme
Parameters:
Name | Type | Description |
---|---|---|
themeName |
string
|
Name of theme |
SVG
# layoutResetNodes()
Helper function to reset all nodes to original default positions
# layoutUpdate(scope)
Update UI, positions of inputs and outputs
Parameters:
Name | Type | Description |
---|---|---|
scope |
Scope
|
the circuit whose subcircuit we are editing |
# loadModule(data, scope)
Function to load CircuitElements
Parameters:
Name | Type | Description |
---|---|---|
data |
JSON
|
JSOn data |
scope |
Scope
|
circuit in which we want to load modules |
# loadNode(data, scope)
function makes a node according to data providede
Parameters:
Name | Type | Description |
---|---|---|
data |
JSON
|
the data used to load a Project |
scope |
Scope
|
scope to which node has to be loaded |
# loadResult()
Loads result from JSON string into the testbench creator UI
# loadScope(scope, data)
Function to load a full circuit
Parameters:
Name | Type | Description |
---|---|---|
scope |
Scope
|
|
data |
JSON
|
# menuItemClicked(id)
Function is called when context item is clicked
Parameters:
Name | Type | Description |
---|---|---|
id |
number
|
id of the optoin selected |
# newCircuit(name, id)
Function to create new circuit
Function creates button in tab, creates scope and switches to this circuit
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
name of the new circuit |
id |
string
|
identifier for circuit |
# newProject(verify)
Function used to start a new project while prompting confirmation from the user
Parameters:
Name | Type | Description |
---|---|---|
verify |
boolean
|
flag to verify a new project |
# objectSelectionSet(param)
used to set the value of object selection,
Parameters:
Name | Type | Description |
---|---|---|
param |
boolean
|
# onDoubleClickorTap(e)
Parameters:
Name | Type | Description |
---|---|---|
e |
event
|
function for double click or double tap |
# openCreator(type, dataString)
Use this function to navigate to test creator. This function starts the storage listener
so the test is loaded directly into the simulator
Parameters:
Name | Type | Description |
---|---|---|
type |
string
|
'create', 'edit' or 'result' |
dataString |
String
|
data in JSON string to load in case of 'edit' and 'result' |
# paneLayout(scope)
Used to move the grid in the layout mode
Parameters:
Name | Type | Description |
---|---|---|
scope |
Scope
|
the circuit whose subcircuit we are editing |
# paste(copyData)
Helper function to paste
Parameters:
Name | Type | Description |
---|---|---|
copyData |
JSON
|
the data to be pasted |
# play(scopeopt, resetNodes)
Main fn that resolves circuit using event driven simulation
All inputs are added to a scope using scope.addinput() and
the simulation starts to play.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scope |
Scope
|
<optional> |
the circuit we want to simulate |
resetNodes |
boolean
|
boolean to reset all nodes |
# rectifyObjectType(obj)
Backward compatibility - needs to be deprecated
Parameters:
Name | Type | Description |
---|---|---|
obj |
CircuitElement
|
the object to be rectified |
# removeBugNodes()
This function shouldn't ideally exist. But temporary fix
for some issues while loading nodes.
# renderCanvas(scope)
Function to render Canvas according th renderupdate order
Parameters:
Name | Type | Description |
---|---|---|
scope |
Scope
|
The circuit whose canvas we want to render |
# renderLayout(scopeopt)
Function to render layout on screen in layoutMode
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scope |
Scope
|
<optional> |
# replace(node, index)
Fn to replace node by node @ index in global Node List - used when loading
Parameters:
Name | Type | Description |
---|---|---|
node |
Node
|
node to be replaced |
index |
number
|
index of node to be replaced |
# resetup()
to resize window and setup things it
sets up new width for the canvas variables.
Also redraws the grid.
# runAll(data, scopeopt)
Run all the tests automatically. Called by runTestBench()
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Object
|
Object containing Test Data | |
scope |
Scope
|
<optional> |
the circuit |
# runSingleCombinational(data, groupIndex, caseIndex, scope)
Runs single combinational test
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing Test Data |
groupIndex |
number
|
Index of the group to be tested |
caseIndex |
number
|
Index of the case inside the group |
scope |
Scope
|
The circuit |
# runSingleSequential(data, groupIndex, caseIndex, scope)
Runs single sequential test and all tests above it in the group
Used in MANUAL mode
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing Test Data |
groupIndex |
number
|
Index of the group to be tested |
caseIndex |
number
|
Index of the case inside the group |
scope |
Scope
|
The circuit |
# runSingleTest(data, groupIndex, caseIndex, scope)
Runs single test
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing Test Data |
groupIndex |
number
|
Index of the group to be tested |
caseIndex |
number
|
Index of the case inside the group |
scope |
Scope
|
The circuit |
# runTestBench(data, runContextopt, scopeopt)
Interface function to run testbench. Called by testbench prompt on simulator or assignments
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Object
|
Object containing Test Data | |
runContext |
RunContext
|
<optional> |
Whether simulator or Assignment called this function |
scope |
Scope
|
<optional> |
the circuit |
# saveData()
Called when Save is clicked. If opened in popup, sends message to parent window
to attach test to the testbench.
# saveOffline()
Helper function to store to localStorage -- needs to be deprecated/removed
# scheduleUpdate(countopt, timeopt, fn)
Function to check for any UI update, it is throttled by time
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
count |
number
|
<optional> |
this is used to force update |
time |
number
|
<optional> |
the time throttling parameter |
fn |
function
|
function to run before updating UI |
# setInputValues(inputs, group, caseIndex, scope)
Set and propogate the input values according to the testcase.
Called by runSingle() and runAll()
Parameters:
Name | Type | Description |
---|---|---|
inputs |
Object
|
Object with keys as input names and values as inputs |
group |
Object
|
Test group |
caseIndex |
number
|
Index of the case in the group |
scope |
Scope
|
the circuit |
# setProjectName(name)
Function to set the name of project.
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
name for project |
# setUICurrentCase(data, groupIndex, caseIndex)
UI Function
Set current test case data on the UI
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing the test data |
groupIndex |
number
|
Index of the group of current case |
caseIndex |
number
|
Index of the case within the group |
# setUIResult(data, result)
UI Function
Set the current test case result on the UI
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing the test data |
result |
Map
|
Map containing the output values (returned by getOutputValues()) |
# setUITableHeaders(data)
UI Function
Sets IO labels and bitwidths on UI table
Called by simulatorRunTestbench()
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing the test data |
# setup()
The first function to be called to setup the whole simulator
# setupElementLists()
It initializes some useful array which are helpful
while simulating, saving and loading project.
It also draws icons in the sidebar
# setupEnvironment()
function to setup environment variables like projectId and DPR
# setupTestbenchUI()
UI Function
Checks whether test is attached to the scope and switches UI accordingly
# setupUI()
adds some UI elements to side bar and
menu also attaches listeners to sidebar
# showError(error)
Helper function to show error
Parameters:
Name | Type | Description |
---|---|---|
error |
string
|
The error to be shown |
# showProperties(obj)
show properties of an object.
Parameters:
Name | Type | Description |
---|---|---|
obj |
CircuiElement
|
the object whose properties we want to be shown in sidebar |
# showValidationUI(validationErrors)
UI Function
Shows validation UI
Parameters:
Name | Type | Description |
---|---|---|
validationErrors |
Object
|
Object with errors returned by validate() |
# solveBooleanFunction(inputListNames, booleanExpression)
This function solves passed boolean expression and returns
output array which contains solution of the truth table
of given boolean expression
Parameters:
Name | Type | Description |
---|---|---|
inputListNames |
Array
|
labels for input nodes |
booleanExpression |
String
|
boolean expression which is to be solved |
# switchCircuit(id)
Function used to change the current focusedCircuit
Disables layoutMode if enabled
Changes UI tab etc
Sets flags to make updates, resets most of the things
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
identifier for circuit |
# tickClock(scope)
Ticks clock recursively one full cycle (Only used in testbench context)
Parameters:
Name | Type | Description |
---|---|---|
scope |
Scope
|
the circuit whose clock to be ticked |
# toggleLayoutMode()
Function to toggle between layoutMode and normal Mode
the sidebar is disabled and n properties are shown.
# update(scopeopt, updateEverythingopt)
fn that calls update on everything else. If any change
is there, it resolves the circuit and draws it again.
Also updates simulations, selection, minimap, resolves
circuit and redraws canvas if required.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scope |
Scope
|
<optional> |
the circuit to be updated |
updateEverything |
boolean
|
<optional> |
if true we update the wires, nodes and modules |
# updateCanvasSet(param)
used to set the value of updateCanvas.
Parameters:
Name | Type | Description |
---|---|---|
param |
boolean
|
# updatePositionSet(param)
used to set the value of updatePosition.
Parameters:
Name | Type | Description |
---|---|---|
param |
boolean
|
# updateSelectionsAndPane(scopeopt)
Function to move multiple objects and panes window
deselected using dblclick right now (PR open for esc key)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scope |
Scope
|
<optional> |
the circuit in which we are selecting stuff |
# updateSimulationSet(param)
used to set the value of updateSimulation.
Parameters:
Name | Type | Description |
---|---|---|
param |
boolean
|
# updateSubcircuitSet(param)
used to set updateSubcircuit
Parameters:
Name | Type | Description |
---|---|---|
param |
boolean
|
# updateTestbenchUI()
Updates the TestBench UI on the simulator with the current test attached
If no test is attached then shows the 'No test attached' screen
Called by runTestBench() when test is set, also called by UX/setupPanelListeners()
whenever ux change requires this UI to update(such as clicking on a different circuit or
loading a saved circuit)
# updateThemeForStyle()
Updates theme
1) Sets CSS Variables for UI elements
2) Sets color variable for Canvas elements
# validate(data, scope)
Validate if all inputs and output elements are present with correct bitwidths
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing Test Data |
scope |
Scope
|
the circuit |
# validateInputs(data, scope)
Validates presence and bitwidths of test inputs in the circuit.
Called by validate()
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing Test Data |
scope |
Scope
|
the circuit |
# validateOutputs(data, scope)
Validates presence and bitwidths of test outputs in the circuit.
Called by validate()
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Object containing Test Data |
scope |
Scope
|
the circuit |
# validationAutoFix(validationErrors)
Autofix whatever is possible in validation errors.
returns number of autofixed errors
Parameters:
Name | Type | Description |
---|---|---|
validationErrors |
Object
|
Object with errors returned by validate() |
# wireToBeCheckedSet(param)
Used to set wireChecked boolean which updates wires in UI if true (or 1). 2 if some problem and it is handled.
Parameters:
Name | Type | Description |
---|---|---|
param |
number
|
value of wirechecked |