2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 *------------------------------------------------------------------
22 * current controlled source base
28 /*--------------------------------------------------------------------------*/
29 class INTERFACE CCSRC_BASE
: public ELEMENT
{
33 :ELEMENT(), _input_label(), _input(0) {}
34 explicit CCSRC_BASE(const CCSRC_BASE
& p
)
35 :ELEMENT(p
), _input_label(p
._input_label
), _input(p
._input
) {}
37 protected: // override virtual
38 virtual uint_t
max_nodes()const {assert(input_order()); return 2 + 1*input_order();}
39 virtual uint_t
net_nodes()const {return 2;} // before:2
40 virtual uint_t
ext_nodes()const {return 2*(1+input_order());} // for matrix allocation
41 virtual uint_t
num_current_ports()const {return input_order();}
42 virtual uint_t
ports_per_input()const {return 0;}
43 const std::string
current_port_value(uint_t i
)const {
44 if(i
<_input_label
.size())
45 return _input_label
[i
];
48 // bool do_tr() {_sim->_late_evalq.push_back(this); return true;}
49 bool do_tr_hack() {return do_tr_last();}
50 //void precalc_first(); //ELEMENT
52 //void precalc_last(); //ELEMENT
53 bool tr_needs_eval()const {assert(!is_q_for_eval()); return true;}
54 //void tr_queue_eval() //ELEMENT
55 void tr_unload() {untested(); tr_unload_active();}
56 hp_float_t
tr_involts()const {untested();return dn_diff(_n
[IN1
].v0(), _n
[IN2
].v0());}
57 hp_float_t
tr_input()const {untested(); return _input
->tr_amps();}
58 hp_float_t
tr_involts_limited()const {return volts_limited(_n
[IN1
],_n
[IN2
]);}
59 hp_float_t
tr_input_limited()const {return _input
->tr_amps();}
60 COMPLEX
ac_involts()const {untested();return _n
[IN1
].vac()-_n
[IN2
].vac();}
61 void set_port_by_index(uint_t index
, std::string
& value
);
62 bool node_is_connected(uint_t i
)const;
65 void set_inputs(unsigned node_count
, node_t
* Nodes
);
66 void set_parameters_cc(const std::string
& Label
, CARD
* Parent
,
67 COMMON_COMPONENT
* Common
, double Value
,
68 const node_t
& N0
, const node_t
& N1
,
70 public: //BUG// for language plugin
71 std::vector
<std::string
> _input_label
;
72 const ELEMENT
* _input
;
74 /*--------------------------------------------------------------------------*/
75 /*--------------------------------------------------------------------------*/
77 // vim:ts=8:sw=2:noet: