Warning, file /sdk/ktechlab/src/electronics/simulation/currentsource.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /***************************************************************************
0002  *   Copyright (C) 2003-2004 by David Saxton                               *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #include "currentsource.h"
0012 #include "elementset.h"
0013 
0014 CurrentSource::CurrentSource(const double current)
0015     : Element::Element()
0016 {
0017     m_i = current;
0018     m_numCNodes = 2;
0019 }
0020 
0021 CurrentSource::~CurrentSource()
0022 {
0023 }
0024 
0025 void CurrentSource::setCurrent(const double i)
0026 {
0027     if (i == m_i)
0028         return;
0029 
0030     if (p_eSet)
0031         p_eSet->setCacheInvalidated();
0032 
0033     // Remove the old current
0034     m_i = -m_i;
0035     add_initial_dc();
0036 
0037     m_i = i;
0038     add_initial_dc();
0039 }
0040 
0041 void CurrentSource::add_initial_dc()
0042 {
0043     if (!b_status)
0044         return;
0045 
0046     b_i(0) -= m_i;
0047     b_i(1) += m_i;
0048 }
0049 
0050 void CurrentSource::updateCurrents()
0051 {
0052     m_cnodeI[0] = -m_i;
0053     m_cnodeI[1] = m_i;
0054 }