1 /*$Id: c_prbcmd.cc,v 1.5 2010-07-09 12:14:20 felix Exp $ -*- C++ -*-
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 * probe and plot commands
23 * set up print and plot (select points, maintain probe lists)
24 * command line operations
26 //testing=script,sparse 2006.07.17
27 #include "u_sim_data.h"
31 /*--------------------------------------------------------------------------*/
33 /*--------------------------------------------------------------------------*/
34 void do_probe(CS
& cmd
, PROBELIST
*probes
)
36 CKT_BASE::_sim
->set_command_none();
37 enum {aADD
, aDELETE
, aNEW
} action
;
38 SIM_MODE simtype
= s_NONE
;
40 if (cmd
.match1('-')) {untested(); /* handle .probe - ac ...... */
41 action
= aDELETE
; /* etc. */
43 }else if (cmd
.match1('+')) {untested();
46 }else{ /* no -/+ means clear, but wait for */
47 action
= aNEW
; /* .probe ac + ..... */
48 } /* which will not clear first */
51 || Set(cmd
, "tr{ansient}", &simtype
, s_TRAN
)
52 || Set(cmd
, "tw{ot}", &simtype
, s_TTT
)
53 || Set(cmd
, "tt", &simtype
, s_TTT
)
54 || Set(cmd
, "ac", &simtype
, s_AC
)
55 || Set(cmd
, "dc", &simtype
, s_DC
)
56 || Set(cmd
, "ddc", &simtype
, s_DDC
)
57 || Set(cmd
, "op", &simtype
, s_OP
)
58 || Set(cmd
, "fo{urier}", &simtype
, s_FOURIER
)
59 || Set(cmd
, "sens", &simtype
, s_SENS
)
62 if (!simtype
) { /* must be all simtypes */
63 if (cmd
.is_end()) { /* list all */
64 probes
[s_TRAN
].listing("tran");
65 probes
[s_TTT
].listing("tw");
66 probes
[s_AC
].listing("ac");
67 probes
[s_DC
].listing("dc");
68 probes
[s_DDC
].listing("ddc");
69 probes
[s_OP
].listing("op");
70 probes
[s_FOURIER
].listing("fourier");
71 probes
[s_SENS
].listing("sens");
72 }else if (cmd
.umatch("clear ")) { /* clear all */
73 for (unsigned ii
= sSTART
; ii
< sCOUNT
; ++ii
) {
76 }else{itested(); /* error */
77 throw Exception_CS("what's this?", cmd
);
80 if (cmd
.is_end()) { /* list */
81 probes
[simtype
].listing("");
82 }else if (cmd
.umatch("clear ")) { /* clear */
83 probes
[simtype
].clear();
84 }else{ /* add/remove */
85 trace0("CKT_BASE::_sim->init from print command");
86 CKT_BASE::_sim
->init();
87 if (cmd
.match1('-')) {itested(); /* setup cases like: */
88 action
= aDELETE
; /* .probe ac + .... */
90 }else if (cmd
.match1('+')) {
95 if (action
== aNEW
) { /* no +/- here or at beg. */
96 probes
[simtype
].clear(); /* means clear first */
100 while (cmd
.more()) { /* do-it */
101 if (cmd
.match1('-')) { /* handle cases like: */
102 action
= aDELETE
; /* .pr ac +v(7) -e(6) +r(8) */
104 }else if (cmd
.match1('+')) {itested();
109 if (action
== aDELETE
) {
110 trace0( "do_probe aDELETE" );
111 probes
[simtype
].remove_list(cmd
);
113 trace0("calling add_list");
114 probes
[simtype
].add_list(cmd
);
120 /*--------------------------------------------------------------------------*/
121 class CMD_STORE
: public CMD
{
123 void do_it(CS
& cmd
, CARD_LIST
*)
125 assert(_probe_lists
);
126 assert(_probe_lists
->store
);
127 do_probe(cmd
,_probe_lists
->store
);
130 DISPATCHER
<CMD
>::INSTALL
d0(&command_dispatcher
, "store", &p0
);
131 /*--------------------------------------------------------------------------*/
132 class CMD_ALARM
: public CMD
{
134 void do_it(CS
& cmd
, CARD_LIST
*)
136 assert(_probe_lists
);
137 assert(_probe_lists
->alarm
);
138 do_probe(cmd
,_probe_lists
->alarm
);
141 DISPATCHER
<CMD
>::INSTALL
d1(&command_dispatcher
, "alarm", &p1
);
142 /*--------------------------------------------------------------------------*/
143 class CMD_PLOT
: public CMD
{
145 void do_it(CS
& cmd
, CARD_LIST
*)
148 assert(_probe_lists
);
149 assert(_probe_lists
->plot
);
150 do_probe(cmd
,_probe_lists
->plot
);
153 DISPATCHER
<CMD
>::INSTALL
d2(&command_dispatcher
, "iplot|plot", &p2
);
154 /*--------------------------------------------------------------------------*/
155 class CMD_PRINT
: public CMD
{
157 void do_it(CS
& cmd
, CARD_LIST
*)
160 assert(_probe_lists
);
161 assert(_probe_lists
->print
);
162 do_probe(cmd
,_probe_lists
->print
);
165 DISPATCHER
<CMD
>::INSTALL
d3(&command_dispatcher
, "iprint|print|probe", &p3
);
166 /*--------------------------------------------------------------------------*/
167 class CMD_VERIFY
: public CMD
{
169 void do_it(CS
& cmd
, CARD_LIST
*)
171 assert(_probe_lists
);
172 assert(_probe_lists
->verify
);
173 do_probe(cmd
,_probe_lists
->verify
);
176 DISPATCHER
<CMD
>::INSTALL
d4(&command_dispatcher
, "verify", &p4
);
178 /*--------------------------------------------------------------------------*/
179 /*--------------------------------------------------------------------------*/
180 // vim:ts=8:sw=2:noet: