From 11bafd70eaf1dc608a7fee8ef1d36df6df8c3593 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Fri, 21 Jul 2017 15:45:46 +0200 Subject: [PATCH] update to callback functions SendEvtData, SendInitEvtData --- src/include/ngspice/sharedspice.h | 27 +++++++++++++++++++++++---- src/sharedspice.c | 6 +++--- src/xspice/evt/evtdump.c | 17 ++++------------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/include/ngspice/sharedspice.h b/src/include/ngspice/sharedspice.h index 19adde5e9..ae91b300e 100644 --- a/src/include/ngspice/sharedspice.h +++ b/src/include/ngspice/sharedspice.h @@ -285,11 +285,30 @@ typedef int (GetSyncData)(double, double*, double, int, int, int, void*); /* callback functions addresses received from caller with ngSpice_Init_Evt() function */ -typedef int (SendEvtData)(int, double, double, char *, void *, int, int, void*); -/* int index, double step, double dvalue, char *svalue, void *pvalue, int plen, int mode */ -typedef int (SendInitEvtData)(char*, void*); + +/* Upon time step finished, called per node */ +typedef int (SendEvtData)(int, double, double, char *, void *, int, int, int, void*); /* - char* string with node info: "index name udn-name" + int node index + double step, actual simulation time + double dvalue, a real value for specified structure component for plotting purposes + char *svalue, a string value for specified structure component for printing + void *pvalue, a binary data structure + int plen, size of the *pvalue structure + int mode, the mode (op, dc, tran) we are in + int ident, identification number of calling ngspice shared lib + void* return pointer received from caller +*/ + +/* Upon initialization, called once per event node + To build up a dictionary of nodes */ +typedef int (SendInitEvtData)(int, int, char*, char*, int, void*); +/* + int node index + int maximum node index, number of nodes + char* node name + char* udn-name, node type + int identification number of calling ngspice shared lib void* return pointer received from caller */ #endif diff --git a/src/sharedspice.c b/src/sharedspice.c index c6d5449ea..0e76abb3e 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -1949,13 +1949,13 @@ sharedsync(double *pckttime, double *pcktdelta, double olddelta, double finalt, void shared_send_event(int index, double step, double dvalue, char *svalue, void *pvalue, int plen, int mode) { if(wantevtdata) - sendevt(index, step, dvalue, svalue, pvalue, plen, mode, euserptr); + sendevt(index, step, dvalue, svalue, pvalue, plen, mode, ng_ident, euserptr); return; } -void shared_send_dict(char* dictline) +void shared_send_dict(int index, int no_of_nodes, char* name, char*type) { if (sendinitevt) - sendinitevt(dictline, euserptr); + sendinitevt(index, no_of_nodes, name, type, ng_ident, euserptr); } diff --git a/src/xspice/evt/evtdump.c b/src/xspice/evt/evtdump.c index 87e77c455..4bbdc17a4 100644 --- a/src/xspice/evt/evtdump.c +++ b/src/xspice/evt/evtdump.c @@ -61,8 +61,8 @@ NON-STANDARD FEATURES #ifdef SHARED_MODULE /* global flag, TRUE if callback is used */ extern bool wantevtdata; -extern void shared_send_event(int, double, double, char *, void *, int); -extern void shared_send_dict(char*); +extern void shared_send_event(int, double, double, char *, void *, int, int); +extern void shared_send_dict(int, int, char*, char*); static void EVTshareddump( CKTcircuit *ckt, /* The circuit structure */ Ipc_Anal_t mode, /* The analysis mode for this call */ @@ -403,8 +403,6 @@ static void EVTshareddump( Evt_Node_Info_t **node_table; - char buff[10000]; - Mif_Boolean_t equal; /* Get number of event-driven nodes */ @@ -474,16 +472,9 @@ static void EVTshareddump( /* If this is the first call, send the dictionary (the list of event nodes, line by line) */ if (firstcall) { for (i = 0; i < num_nodes; i++) { - if (node_dict[i].send) { - sprintf(buff, "%d %s %s", node_dict[i].ipc_index, - node_dict[i].node_name_str, - node_dict[i].udn_type_str); - /* send it directly to sharedspice.c */ - shared_send_dict(buff); - } + if (node_dict[i].send) + shared_send_dict(node_dict[i].ipc_index, num_nodes, node_dict[i].node_name_str, node_dict[i].udn_type_str); } - /* last entry to list */ - shared_send_dict(NULL); } /* If this is the first call, send the operating point solution */