public class Circuit extends java.lang.Object implements Logic
Constructor and Description |
---|
Circuit(java.lang.String circuitName)
This constructor will construct a Circuit by given the name of the circuit
To do this I will follow this steps
*1.initialize all fields, first thing (including empty lists).
|
Circuit(java.lang.String circuitName,
java.util.List<Logic> components,
java.util.List<Contact> inputs,
java.util.List<Contact> outputs,
java.util.List<Wire> innerWires,
java.util.List<java.lang.String> importables)
Circuit constructor, construct the design of contact class
|
Modifier and Type | Method and Description |
---|---|
void |
feed(java.util.List<Signal> inSigs)
feed method feeds these signal values to the inputs contacts.
|
void |
feed(java.lang.String s)
feed method feeds these String into inputs list
|
Wire |
findWire(java.lang.String name)
findWire finds if this wire exist on innerWire and return the wire if not return null
|
java.util.Scanner |
getCircuitScanner(java.lang.String circuitName)
getCircuitScanner will create a scanner that will read file of format .txr on samples folder.
|
java.util.List<Logic> |
getComponents()
getComponents
|
java.util.List<java.lang.String> |
getImportables()
getImportables
|
java.util.List<Wire> |
getInnerWires()
getInnerWires
|
java.util.List<Contact> |
getInputs()
getInputs
|
java.lang.String |
getName()
getName
|
java.util.List<Contact> |
getOutputs()
getOutputs
|
void |
hookUp(java.util.List<Wire> inWires,
java.util.List<Wire> outWires)
hookUp will connect togother the wire from outside to the wire inside the circuit
inWires will be set on inputs contact in Wire and outWire will be set on the outputs
contact out Wire.
|
static java.lang.String |
indent(java.lang.String s)
indent method add indent to the string of lines
|
java.util.List<Signal> |
inspect(java.util.List<Signal> inputs)
A combination of feeding, propagating, and reading.
|
java.lang.String |
inspect(java.lang.String inputs)
We will return the String of the inputs that we did in previous
method.
|
void |
parseComponentLine(java.lang.String line)
parseComponentLine reads the line and check if it has sub-circuit in it if not has a gate.
|
void |
parseContactsLine(java.lang.String line)
parseContactsLine reads each line of string and creates new wires and store them at innerWires
list and for each one, create a Contact and appropriately add it to either inputs or outputs.
|
void |
parseImportLine(java.lang.String line)
parseImportLine reads a line of string that have Import word on it and stores each of other
tokens in list importables but not the import word.
|
boolean |
propagate()
propagate fully update all outputs of all components in this circuit so that all
signal values are stable.
|
java.util.List<Signal> |
read()
reads the signal values from the outputs contact, and create a list of singls of outputs
|
void |
setComponents(java.util.List<Logic> components)
setComponents sets the components to parameter value
|
void |
setImportables(java.util.List<java.lang.String> importables)
setImportables sets the importables to parameter value
|
void |
setInnerWires(java.util.List<Wire> innerWires)
setInnerWires sets the innerWires to parameter value
|
void |
setInputs(java.util.List<Contact> inputs)
setInputs sets the inputs to parameter value
|
void |
setName(java.lang.String name)
setName sets the name to parameter value
|
void |
setOutputs(java.util.List<Contact> outputs)
setOutputs sets the outputs to parameter value
|
java.lang.String |
toString()
toString return the repersantion of the Circuit in strings.
|
public Circuit(java.lang.String circuitName, java.util.List<Logic> components, java.util.List<Contact> inputs, java.util.List<Contact> outputs, java.util.List<Wire> innerWires, java.util.List<java.lang.String> importables)
circuitName
- the name of circuit.components
- The list of logical blocks that are wired together in this circuit.inputs
- the list of contacts that are all inputs.outputs
- the list of contacts that are all outputs.innerWires
- a list were we store all are inner wires.importables
- a list of names that we will import sub-circuits.public Circuit(java.lang.String circuitName) throws java.io.IOException
java.io.IOException
public java.util.Scanner getCircuitScanner(java.lang.String circuitName) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public void parseImportLine(java.lang.String line)
public void parseContactsLine(java.lang.String line)
public Wire findWire(java.lang.String name)
public void hookUp(java.util.List<Wire> inWires, java.util.List<Wire> outWires)
ExceptionLogicParameters
- if the numbere of wire doesnt match.public void parseComponentLine(java.lang.String line) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String indent(java.lang.String s)
public void feed(java.util.List<Signal> inSigs)
feed
in interface Logic
inSigs
- are the list that will assing the wireExceptionLogicParameters
- value if the inSigs size is not equal to inputs size.public void feed(java.lang.String s)
public java.util.List<Signal> read()
public boolean propagate()
public java.util.List<Signal> inspect(java.util.List<Signal> inputs)
public java.lang.String inspect(java.lang.String inputs)
public void setComponents(java.util.List<Logic> components)
components
- the value to set the componentspublic java.util.List<Logic> getComponents()
public void setInputs(java.util.List<Contact> inputs)
inputs
- the value to set the inputspublic java.util.List<Contact> getInputs()
public void setOutputs(java.util.List<Contact> outputs)
outputs
- the value to set the outputspublic java.util.List<Contact> getOutputs()
public void setInnerWires(java.util.List<Wire> innerWires)
innerWires
- the value to set the innerWirespublic java.util.List<Wire> getInnerWires()
public void setImportables(java.util.List<java.lang.String> importables)
importables
- the value to set the importablespublic java.util.List<java.lang.String> getImportables()
public void setName(java.lang.String name)
name
- the value to set the namepublic java.lang.String getName()