Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

void CircuitDocument::splitIntoCircuits ( PinList *  pinList  )  [private]

Takes the nodeList (generated by getPartition), splits it at ground nodes, and creates circuits from each split.

Definition at line 539 of file circuitdocument.cpp.

References createCircuit(), getPartition(), Circuit::identifyGround(), recursivePinAdd(), and tryAsLogicCircuit().

{
      // First: identify ground
      PinList unassignedPins = *pinList;
      typedef QValueList<PinList> PinListList;
      PinListList pinListList;
      while ( !unassignedPins.isEmpty() )
      {
            PinList tempPinList;
            getPartition( *unassignedPins.begin(), & tempPinList, & unassignedPins, true );
            pinListList.append(tempPinList);
      }
      const PinListList::iterator nllEnd = pinListList.end();
      for ( PinListList::iterator it = pinListList.begin(); it != nllEnd; ++it )
            Circuit::identifyGround(*it);
      
      

      bool allGround = false;
      while ( !pinList->isEmpty() && !allGround )
      {
            PinList::iterator end = pinList->end();
            PinList::iterator it = pinList->begin();
            
            while ( it != end && (*it)->eqId() == -1 )
                  ++it;
            
            if ( it == end )
                  allGround = true;
            
            else
            {
                  Circuitoid *circuitoid = new Circuitoid;
                  recursivePinAdd( *it, circuitoid, pinList );
                  
                  if ( !tryAsLogicCircuit(circuitoid) )
                        m_circuitList += createCircuit(circuitoid);
                  
                  delete circuitoid;
            }
      }
      
      
      // Remaining pins are ground; tell them about it
      // TODO This is a bit hacky....
      const PinList::iterator end = pinList->end();
      for ( PinList::iterator it = pinList->begin(); it != end; ++it )
      {
            (*it)->setVoltage(0.0);
            
            ElementList elements = (*it)->elements();
            const ElementList::iterator eEnd = elements.end();
            for ( ElementList::iterator it = elements.begin(); it != eEnd; ++it )
            {
                  if ( LogicIn * logicIn = dynamic_cast<LogicIn*>(*it) )
                  {
                        logicIn->setLastState(false);
                        logicIn->callCallback();
                  }
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index