From bbb00074661d925be2a20d97b45a626d7b4aa075 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 18 Apr 2020 14:01:26 +0200 Subject: [PATCH] add function EVTswitch_plot() to switch the event data according tothe (analog) plot. Called from plot_setcur() in vetors.c, when command 'setplot xxx' is given. --- src/frontend/vectors.c | 6 +++--- src/include/ngspice/evt.h | 1 + src/xspice/evt/evtprint.c | 2 +- src/xspice/evt/evtsetup.c | 38 +++++++++++++++++++++++++++++++++++++- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index d6ef08bbd..74cf70263 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -33,11 +33,9 @@ static struct dvec *find_permanent_vector_by_name( static enum ALL_TYPE_ENUM get_all_type(const char *word); static bool plot_prefix(const char *pre, const char *str); - #ifdef XSPICE -/* gtri - begin - add function prototype for EVTfindvec */ +extern int EVTswitch_plot(CKTcircuit* ckt, const char* plottypename); struct dvec *EVTfindvec(char *node); -/* gtri - end - add function prototype for EVTfindvec */ #endif @@ -1133,6 +1131,7 @@ void plot_setcur(const char *name) } if (prev_pl) { /* found */ plot_cur = prev_pl; + EVTswitch_plot(ft_curckt->ci_ckt, plot_cur->pl_typename); } else { /* no next plot */ fprintf(cp_err, @@ -1157,6 +1156,7 @@ void plot_setcur(const char *name) plot_cur->pl_ccom = cp_kwswitch(CT_VECTOR, pl->pl_ccom); } */ + EVTswitch_plot(ft_curckt->ci_ckt, name); plot_cur = pl; } /* end of function plot_setcur */ diff --git a/src/include/ngspice/evt.h b/src/include/ngspice/evt.h index 5afe1df92..a9f46c600 100644 --- a/src/include/ngspice/evt.h +++ b/src/include/ngspice/evt.h @@ -334,6 +334,7 @@ struct Evt_Limit { struct Evt_Job { int num_jobs; /* Number of jobs run */ + int cur_job; /* job selected for plotting etc */ char **job_name; /* Names of different jobs */ char **job_plot; /* Names of different plots created by the job */ Evt_Node_Data_t **node_data; /* node_data for different jobs */ diff --git a/src/xspice/evt/evtprint.c b/src/xspice/evt/evtprint.c index 8bc39c15b..116e0ab45 100644 --- a/src/xspice/evt/evtprint.c +++ b/src/xspice/evt/evtprint.c @@ -413,7 +413,7 @@ EVTdisplay(wordlist *wl) out_printf("No event node available!\n"); return; } - out_printf("\nList of event nodes\n"); + out_printf("\nList of event nodes in plot %s\n", ckt->evt->jobs.job_plot[ckt->evt->jobs.cur_job]); out_printf(" %-20s: %-5s, %s\n\n", "node name", "type", "number of events"); node_index = 0; while (node) { diff --git a/src/xspice/evt/evtsetup.c b/src/xspice/evt/evtsetup.c index d1edce608..ed1a658e4 100644 --- a/src/xspice/evt/evtsetup.c +++ b/src/xspice/evt/evtsetup.c @@ -61,7 +61,7 @@ static int EVTsetup_data(CKTcircuit *ckt); static int EVTsetup_jobs(CKTcircuit *ckt); static int EVTsetup_load_ptrs(CKTcircuit *ckt); -int EVTsetup_plot(CKTcircuit* ckt, char* plotname); +int EVTsetup_plot(CKTcircuit* ckt, char* plottypename); /* Allocation macros with built-in check for out-of-memory */ @@ -610,7 +610,43 @@ int EVTsetup_plot(CKTcircuit* ckt, char *plotname) { Evt_Job_t* jobs = &(ckt->evt->jobs); if (jobs) { jobs->job_plot[jobs->num_jobs - 1] = copy(plotname); + jobs->cur_job = jobs->num_jobs - 1; return OK; } return 1; } + +/* If command 'setplot' is called, we switch to the corresponding event data. + Their pointers have been stored in the jobs structure.*/ +int EVTswitch_plot(CKTcircuit* ckt, const char* plottypename) { + int i; + bool found = FALSE; + + Evt_Job_t* jobs; + Evt_Data_t* data; + + if (ckt->evt->counts.num_insts == 0) + return(OK); + + jobs = &(ckt->evt->jobs); + data = &(ckt->evt->data); + + if (jobs) { + /* check for the job with current plot type name , e.g. tran2 */ + for (i = 0; i < jobs->num_jobs; i++) { + if (jobs->job_plot[i] && eq(jobs->job_plot[i], plottypename)) { + found = TRUE; + jobs->cur_job = i; + break; + } + } + if (found) { + data->node = jobs->node_data[i]; + data->state = jobs->state_data[i]; + data->msg = jobs->msg_data[i]; + data->statistics = jobs->statistics[i]; + return OK; + } + } + return 1; +}