/*$Id: e_ccsrc.cc,v 26.14 2007/02/07 09:06:48 al Exp $ -*- C++ -*- * Copyright (C) 2001 Albert Davis * Author: Albert Davis * * This file is part of "Gnucap", the Gnu Circuit Analysis Package * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. *------------------------------------------------------------------ * current controlled source base */ //testing=script,complete 2006.07.12 #include "e_ccsrc.h" /*--------------------------------------------------------------------------*/ void CCSRC_BASE::parse_more_nodes(CS& cmd, int) { _input_label = cmd.ctos(TOKENTERM); _input_label[0] = toupper(_input_label[0]); } /*--------------------------------------------------------------------------*/ void CCSRC_BASE::print(OMSTREAM& o, LANGUAGE lang)const { switch (lang) { case lACS:untested(); print_type(o, lang); print_label(o, lang); print_nodes(o, lang); if (_input) { // has been expanded o << " " << _input->short_label(); }else{ // not expanded o << " " << _input_label; /* could always print as not expanded, */ } /* but this way provides error check */ print_args(o, lang); o << '\n'; break; case lSPICE: //print_type(o, lang); ??? print_label(o, lang); print_nodes(o, lang); if (_input) { // has been expanded o << " " << _input->short_label(); }else{ // not expanded o << " " << _input_label; /* could always print as not expanded, */ } /* but this way provides error check */ print_args(o, lang); o << '\n'; break; case lVERILOG:itested(); print_type(o, lang); print_args(o, lang); print_label(o, lang); print_nodes(o, lang); if (_input) {itested(); // has been expanded o << " " << _input->short_label(); }else{itested(); // not expanded o << " " << _input_label; /* could always print as not expanded, */ } /* but this way provides error check */ o << ";\n"; break; case lAUTO: unreachable(); break; } } /*--------------------------------------------------------------------------*/ void CCSRC_BASE::elabo1() { ELEMENT::elabo1(); if (!_input_label.empty()) { _input = dynamic_cast(find_in_my_scope(_input_label,bERROR)); }else{ // _input already set, an internal element. example: mutual L. } if (!_input || _input->is_2port() || _input->subckt()) { error(bERROR, long_label() + ": " + _input_label + " cannot be used as current probe\n"); } assert(_input->is_1port() || _input->is_source()); _n[IN1] = _input->_n[OUT1]; _n[IN2] = _input->_n[OUT2]; //_n[IN1].e = _n[IN2].e = INVALID_NODE; } /*--------------------------------------------------------------------------*/ void CCSRC_BASE::set_parameters_cc(const std::string& Label, CARD *Owner, COMMON_COMPONENT *Common, double Value, const node_t& N0, const node_t& N1, ELEMENT* Input) { node_t nodes[] = {N0, N1}; COMPONENT::set_parameters(Label, Owner, Common, Value, 0, 0, 2, nodes); _input = Input; } /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/