Circuit Class Reference

Simulates a collection of components. More...

#include <circuit.h>

Collaboration diagram for Circuit:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Circuit ()
 ~Circuit ()
void addPin (Pin *node)
void addElement (Element *element)
bool contains (Pin *node)
bool containsNonLinear () const
void init ()
void initCache ()
void setCacheInvalidated ()
void doNonLogic ()
void doLogic ()
void displayEquations ()
void updateCurrents ()
void createMatrixMap ()
void setNextChanged (Circuit *circuit, unsigned char chain)
CircuitnextChanged (unsigned char chain) const
void setCanAddChanged (bool canAdd)
bool canAddChanged () const

Static Public Member Functions

static int identifyGround (PinList nodeList, int *highest=0)

Protected Member Functions

void cacheAndUpdate ()
void updateNodalVoltages ()
void stepReactive ()

Static Protected Member Functions

static bool recursivePinAdd (Pin *node, PinList *unassignedNodes, PinList *associated, PinList *nodes)

Protected Attributes

int m_cnodeCount
int m_branchCount
int m_prepNLCount
PinList m_pinList
ElementList m_elementList
ElementSetm_elementSet
bool m_bCanCache
LogicCacheNodem_pLogicCacheBase
unsigned m_logicOutCount
LogicOut ** m_pLogicOut
bool m_bCanAddChanged
Circuitm_pNextChanged [2]

Detailed Description

Simulates a collection of components.

Usage of this class (usually invoked from CircuitDocument): (1) Add Wires, Pins and Elements to the class as appropriate (2) Call init to initialize the simulation (3) Control the simulation with step()

This class can be considered a bridge between the gui-tainted CircuitDocument - specific to this implementation, and the pure untainted ElementSet. Please keep it that way.

Author:
David Saxton

Definition at line 52 of file circuit.h.


Member Function Documentation

void Circuit::initCache (  ) 

Called after everything else has been setup - before doNonLogic or doLogic are called for the first time. Preps the circuit.

Definition at line 277 of file circuit.cpp.

References m_bCanCache, m_elementList, m_elementSet, m_logicOutCount, m_pLogicCacheBase, m_pLogicOut, and ElementSet::updateInfo().

void Circuit::setCacheInvalidated (  ) 

Marks all cached results as invalidated and removes them.

Definition at line 330 of file circuit.cpp.

References LogicCacheNode::data, LogicCacheNode::high, LogicCacheNode::low, and m_pLogicCacheBase.

Referenced by ElementSet::setCacheInvalidated().

void Circuit::doNonLogic (  ) 

Solves for non-logic elements

Definition at line 403 of file circuit.cpp.

References ElementSet::b(), cacheAndUpdate(), ElementSet::containsNonLinear(), ElementSet::doLinear(), ElementSet::doNonLinear(), Matrix::isChanged(), QuickVector::isChanged(), m_bCanCache, m_branchCount, m_cnodeCount, m_elementSet, ElementSet::matrix(), QuickVector::setUnchanged(), stepReactive(), and updateNodalVoltages().

void Circuit::doLogic (  )  [inline]

Solves for logic elements (i.e just does fbSub)

Definition at line 85 of file circuit.h.

References ElementSet::doLinear(), and m_elementSet.

int Circuit::identifyGround ( PinList  nodeList,
int *  highest = 0 
) [static]

This will identify the ground node and non-ground nodes in the given set. Ground will be given the eqId -1, non-ground of 0.

Parameters:
highest The highest ground type of the groundnodes found. If no ground nodes were found, this will be (gt_never-1).
Returns:
the number of ground nodes. If all nodes are at or below the gt_never threshold, then this will be zero.

Definition at line 69 of file circuit.cpp.

References recursivePinAdd().

void Circuit::updateNodalVoltages (  )  [protected]

Update the nodal voltages from those calculated in ElementSet

Definition at line 436 of file circuit.cpp.

References ElementSet::cnodes(), m_elementSet, m_pinList, and CNode::v.

Referenced by doNonLogic().

void Circuit::stepReactive (  )  [protected]

Step the reactive elements.

Definition at line 426 of file circuit.cpp.

References m_elementList.

Referenced by doNonLogic().

bool Circuit::recursivePinAdd ( Pin node,
PinList *  unassignedNodes,
PinList *  associated,
PinList *  nodes 
) [static, protected]

Returns true if any of the nodes are ground

Definition at line 377 of file circuit.cpp.

Referenced by identifyGround(), and init().


The documentation for this class was generated from the following files:
Generated on Tue May 8 17:05:35 2007 for KTechLab by  doxygen 1.5.1