-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbm_value.cc
144 lines (142 loc) · 5.38 KB
/
bm_value.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*$Id: bm_value.cc,v 26.137 2010/04/10 02:37:33 al Exp $ -*- C++ -*-
* Copyright (C) 2001 Albert Davis
* (C) 2015 Felix Salfelder
*
* 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 3, 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.
*------------------------------------------------------------------
* behavioral modeling simple value
* used with tc, etc, and conditionals
*
* QUCS variation
*/
#include "globals.h"
#include "bm.h"
#include <map> // parameter dictionaries
#include "boost/assign.hpp" // initialization templates
/*--------------------------------------------------------------------------*/
using std::string;
using std::map;
namespace{
/*--------------------------------------------------------------------------*/
class EVAL_BM_VALUE : public EVAL_BM_ACTION_BASE {
private:
explicit EVAL_BM_VALUE(const EVAL_BM_VALUE& p):EVAL_BM_ACTION_BASE(p) { untested();}
static std::map<string, const char*> _param_dict;
public:
explicit EVAL_BM_VALUE(int c=0) :EVAL_BM_ACTION_BASE(c) {
trace0("EVAL_BM_VALUE(c)");
}
~EVAL_BM_VALUE() { trace0("~EVAL_BM_VALUE");}
private: // override virtual
bool operator==(const COMMON_COMPONENT&)const override;
COMMON_COMPONENT* clone()const override { untested(); return new EVAL_BM_VALUE(*this);}
void print_common_obsolete_callback(OMSTREAM&, LANGUAGE*)const override;
bool is_trivial()const override;
void precalc_first(const CARD_LIST*)override;
void tr_eval(ELEMENT*)const override;
std::string name()const override { untested();return "value";}
bool ac_too()const override { untested();return false;}
bool parse_numlist(CS&) override;
// bool parse_params_obsolete_callback(CS&);
bool is_constant()const{ untested();return true;}
int set_param_by_name(string Name, string Value)override;
// doesnt make sense. set value through device
// void set_param_by_name(string Name, string Value);
};
static EVAL_BM_VALUE p1(CC_STATIC);
static DISPATCHER<COMMON_COMPONENT>::INSTALL d1(&bm_dispatcher, "qucs_value", &p1);
/*--------------------------------------------------------------------------*/
bool EVAL_BM_VALUE::operator==(const COMMON_COMPONENT& x)const
{ untested();
const EVAL_BM_VALUE* p = dynamic_cast<const EVAL_BM_VALUE*>(&x);
return p && EVAL_BM_ACTION_BASE::operator==(x);
}
/*--------------------------------------------------------------------------*/
void EVAL_BM_VALUE::print_common_obsolete_callback(OMSTREAM& o, LANGUAGE*)const
{ untested();
o << " INCOMPLETE. do not have spice representation (yet).";
}
/*--------------------------------------------------------------------------*/
bool EVAL_BM_VALUE::is_trivial()const
{ untested();
return !(_bandwidth.has_hard_value()
|| _delay.has_hard_value()
|| _phase.has_hard_value()
|| _ooffset.has_hard_value()
|| _ioffset.has_hard_value()
|| _scale.has_hard_value()
|| _tc1.has_hard_value()
|| _tc2.has_hard_value()
|| _ic.has_hard_value()
|| _tnom_c.has_hard_value()
|| _dtemp.has_hard_value()
|| _temp_c.has_hard_value());
}
/*--------------------------------------------------------------------------*/
void EVAL_BM_VALUE::precalc_first(const CARD_LIST* Scope)
{ untested();
trace2("QUCS_VALUE, precalc_first", modelname(), _value);
if (modelname() != "") { untested();
// no. we use set_param stuff.
// _value = modelname();
}else{ untested();
}
EVAL_BM_ACTION_BASE::precalc_first(Scope);
}
/*--------------------------------------------------------------------------*/
void EVAL_BM_VALUE::tr_eval(ELEMENT* d)const
{ untested();
tr_finish_tdv(d, _value);
}
/*--------------------------------------------------------------------------*/
bool EVAL_BM_VALUE::parse_numlist(CS& cmd)
{ untested();
size_t here = cmd.cursor();
PARAMETER<double> new_value(NOT_VALID);
new_value.obsolete_parse(cmd);
if (cmd.gotit(here)) { untested();
_value = new_value;
return true;
}else{ untested();
return false;
}
}
/*--------------------------------------------------------------------------*/
// from EVAL_BM_ACTION_BASE
// changed to qucs names.
map<string, const char*> EVAL_BM_VALUE::_param_dict =
boost::assign::map_list_of
("Tc1", "tc1")
("Tc2", "tc2")
("Temp", "temp")
("ic", "ic");
/*--------------------------------------------------------------------------*/
int EVAL_BM_VALUE::set_param_by_name(string Name, string Value)
{ untested();
const char* n = _param_dict[Name];
if(n) { untested();
Name = n;
}else{ untested();
}
trace2("value wrapper", Name, Value);
return EVAL_BM_ACTION_BASE::set_param_by_name(Name, Value);
}
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
}
// vim:ts=8:sw=2:noet: