Browse Source

Finish first batch of imports from espice.

pre-master-46
pnenzi 17 years ago
parent
commit
1ada4d3530
  1. 22
      ChangeLog
  2. 16
      src/frontend/commands.c
  3. 9
      src/frontend/misccoms.c
  4. 91
      src/frontend/mw_coms.c
  5. 20
      src/frontend/runcoms.c
  6. 3
      src/include/fteext.h

22
ChangeLog

@ -1,3 +1,25 @@
2009-01-16 Paolo Nenzi
* src/frontend/mw_coms.c, src/frontend/commands.c,
* src/frontend/runcoms.c, src/include/fteext.h:
34,
36,
38: Added the removecirc command. This command removes the current
circuit and its associated plots. This comes from an old function
written by M. Widlok and updated by A. Roldan for espice.
Note: I have changed the code to eliminate GTK functions and tested.
Things work but in ngspice there is a problem due to model redefinitions,
as it seems that in ngspice models are globals. Need further
investigation. P. Nenzi
* src/frontend/commands.c, src/frontend/misccomms.c:
24: Added the parameter "noask" to quit command to avoid the question
before exiting ngspice. A. Roldan - Espice
* src/frontend/evaluate.c, src/frontend/typedefs.c, src/include/sim.h:
Added some vector types from Espice (impedance, admittance, power etc.)
The original implementation by A. Roldan did not fit immediatly. I had
to comment two definitions. I could not test "plotab".
2009-01-16 Paolo Nenzi
* src/frontend/evaluate.c, src/frontend/typedefs.c, src/include/sim.h:
Added some vector types from Espice (impedance, admittance, power etc.)

16
src/frontend/commands.c

@ -375,8 +375,13 @@ struct comm spcp_coms[] = {
{ 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS,
(void (*)()) NULL,
"[command name] ... : Print help." } ,
/* to remove circuits loaded */
{ "removecirc", com_removecirc, FALSE, TRUE, FALSE,
{ 04, 0, 0, 0 }, E_DEFHMASK, 0, 1,
(void (*)()) NULL,
"[circuit name] : Remove the current circuit from memory." } ,
{ "quit", com_quit, FALSE, FALSE, TRUE,
{ 0, 0, 0, 0 }, E_BEGINNING, 0, 0,
{ 0, 0, 0, 0 }, E_BEGINNING, 0, 1,
(void (*)()) NULL,
": Quit %s." } ,
{ "source", com_source, FALSE, FALSE, TRUE,
@ -544,7 +549,7 @@ struct comm nutcp_coms[] = {
{ 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1,
(void (*)()) NULL,
"[plotname] : Change the current working plot." } ,
{ "setcirc", NULL, FALSE, TRUE, FALSE,
{ "setcirc", com_scirc, FALSE, TRUE, FALSE,
{ 04, 0, 0, 0 }, E_DEFHMASK, 0, 1,
(void (*)()) NULL,
"[circuit name] : Change the current circuit." } ,
@ -725,9 +730,14 @@ struct comm nutcp_coms[] = {
(void (*)()) NULL,
"[command name] ... : Print help." } ,
{ "quit", com_quit, FALSE, FALSE, TRUE,
{ 0, 0, 0, 0 }, E_BEGINNING, 0, 0,
{ 0, 0, 0, 0 }, E_BEGINNING, 0, 1,
(void (*)()) NULL,
": Quit %s." } ,
/* to remove circuits loaded */
{ "removecirc", com_removecirc, FALSE, TRUE, FALSE,
{ 04, 0, 0, 0 }, E_DEFHMASK, 0, 1,
(void (*)()) NULL,
"[circuit name] : Remove the current circuit from memory." } ,
{ "source", nutcom_source, FALSE, FALSE, TRUE,
{ 1, 1, 1, 1 }, E_DEFHMASK, 1, LOTS,
(void (*)()) NULL,

9
src/frontend/misccoms.c

@ -38,7 +38,14 @@ com_quit(wordlist *wl)
(void) cp_getvar("noaskquit", VT_BOOL, (char *) &noask);
gr_clean();
cp_ccon(FALSE);
if(wl)
if(wl->wl_word)
if(cieq(wl->wl_word,"noask"))
{
byemesg();
exit(EXIT_NORMAL);
}
/* Make sure the guy really wants to quit. */
if (!ft_nutmeg && !noask) {
for (cc = ft_circuits; cc; cc = cc->ci_next)

91
src/frontend/mw_coms.c

@ -21,7 +21,16 @@ com_removecirc(wordlist *wl)
{
struct variable *v, *next;
struct circ *ct;
struct circ *caux=NULL;
struct plot *p;
struct plot *paux;
struct wordlist *wlist;
int auxCir=1,i,auxPlot;
/* Allocation of a temp wordlist */
wlist = (struct wordlist *)malloc(sizeof(struct wordlist));
char buf[80];
if (ft_curckt == NULL) {
fprintf(cp_err, "Error: there is no circuit loaded.\n");
return;
@ -36,8 +45,88 @@ com_removecirc(wordlist *wl)
}
ct->ci_vars = NULL;
caux=ft_circuits;
char* namecircuit = strdup(ft_curckt->ci_name);
/* The circuit being removed is the first loaded and you have more circuits */
if(ft_curckt==ft_circuits&&ft_circuits->ci_next!=NULL)
ft_circuits=ft_circuits->ci_next;
/* The circuit being removed id the first loaded and there are no more circuits */
else if(ft_circuits->ci_next==NULL)
ft_circuits=NULL;
else {
/* Run over the circuit list to find how many of them are
* in front of the one to be removed
*/
for (; ft_curckt != caux&&caux; caux = caux->ci_next)
auxCir++;
caux=ft_circuits;
/* Remove the circuit and move pointer to the next one */
for(i=1;i<auxCir-1;i++)
caux=caux->ci_next;
caux->ci_next=caux->ci_next->ci_next;
/* ft_curckt=ft_circuits; */
}
/* If the plot is ther first one and there are no other plots */
if(plot_list->pl_next==NULL&&strcmp(plot_list->pl_title,namecircuit)==0)
plot_list=NULL;
else if(plot_list&&plot_list->pl_next!=NULL){
p = plot_list;
while(p){
auxPlot=1;
/* If the plot is in the first position */
if(plot_list->pl_next&&strcmp(plot_list->pl_title,namecircuit)==0)
plot_list=plot_list->pl_next;
/* otherwise we run over the list of plots */
else {
for (; strcmp(p->pl_title,namecircuit)!=0&&p->pl_next!=NULL; p = p->pl_next)
auxPlot++;
if(strcmp(p->pl_title,namecircuit)==0){
paux = plot_list;
for(i=1;i<auxPlot-1;i++)
paux=paux->pl_next;
paux->pl_next=paux->pl_next->pl_next;
}
}
p=p->pl_next;
}
}
/*if (ft_curckt) {
ft_curckt->ci_devices = cp_kwswitch(CT_DEVNAMES, ft_circuits->ci_devices);
ft_curckt->ci_nodes = cp_kwswitch(CT_NODENAMES, ft_circuits->ci_nodes);
}*/
if(ft_circuits&&caux->ci_next){
sprintf(buf,"%d",auxCir);
wlist->wl_next = NULL;
wlist->wl_prev = NULL;
wlist->wl_word = buf;
com_scirc(wlist);
free(wlist);
}
else if(ft_circuits){
sprintf(buf,"%d",(auxCir-1));
wlist->wl_next = NULL;
wlist->wl_prev = NULL;
wlist->wl_word = buf;
com_scirc(wlist);
free(wlist);
}
else
ft_curckt=NULL;
return;
}

20
src/frontend/runcoms.c

@ -73,12 +73,20 @@ com_scirc(wordlist *wl)
return;
for (p = ft_circuits; --i > 0; p = p->ci_next);
} else {
for (p = ft_circuits; p; p = p->ci_next)
if (ciprefix(wl->wl_word, p->ci_name))
break;
if (p == NULL) {
fprintf(cp_err, "Warning: no such circuit \"%s\"\n",
wl->wl_word);
for (p = ft_circuits; p; p = p->ci_next)
j++;
p=NULL;
if ((sscanf(wl->wl_word, " %d ", &i) != 1) || (i < 0) || (i > j));
else
for (p = ft_circuits; --i > 0; p = p->ci_next);
/* for (p = ft_circuits; p; p = p->ci_next)
* if (ciprefix(wl->wl_word, p->ci_name))
* break;
*/
if (p == NULL)
{
fprintf(cp_err, "Warning: no such circuit \"%s\"\n",wl->wl_word);
return;
}
fprintf(cp_out, "\t%s\n", p->ci_name);

3
src/include/fteext.h

@ -329,6 +329,9 @@ extern void com_version();
extern int hcomp();
extern void com_where();
/* mw_coms.c */
extern void com_removecirc();
/* numparse.c */
extern bool ft_strictnumparse;

Loading…
Cancel
Save